What does the following statement do? double[] array1 = new double[10]; a. Declares array1 to be a reference to an array of double values |
d. All of these |
To return an array of long values from a method, use this as the return type for the method. a. long[ARRAY_SIZE] |
b. long[] |
It is common practice to use a ________ variable as a size declarator. a. final |
a. final |
If numbers is a two-dimensional array, which of the following would give the length of row r? a. numbers[r].length[r] |
d. numbers[r].length |
Subscript numbering always starts at what value? a. 0 |
a. 0 |
What do you call the number that is used as an index to pinpoint a specific element within an array? a. global unique identifier |
c. subscript |
Java performs ________, which means that it does not allow a statement to use a subscript that is outside the range of valid subscripts for the array. a. active array sequencing |
c. array bounds checking |
The following statement creates an ArrayList object. What is the purpose of the <String> notation? ArrayList<String> arr = new ArrayList<String>(); a. It specifies that String objects may not be stored in the ArrayList object. |
d. It specifies that only String objects may be stored in the ArrayList object. |
What will be returned from the following method? public static float[] getValue(int x) a. An array of float values |
a. An array of float values |
For the following code, what would be the value of str[2]? String[] str = {"abc", "def", "ghi", "jkl"}; a. A reference to the String "def" |
b. A reference to the String "ghi" |
In order to do a binary search on an array: a. the values of the array must be numeric |
b. the array must first be sorted in ascending order |
In Java, you do not use the new operator when you use a(n): a. array size declarator |
b. initialization list |
This indicates the number of elements, or values, the array can hold. a. the array’s data type |
b. the array’s size declarator |
What will be the result of executing the following code? int[] x = {0, 1, 2, 3, 4, 5}; a. The program will crash when it is executed. |
c. An array of 6 values ranging from 0 through 5 and referenced by the variable x will be created. |
What is the value of scores[2][3] in the following array? int [][] scores = { {88, 80, 79, 92}, {75, 84, 93, 80}, {98, 95, 92, 94}, {91, 84, 88, 96} }; a. 84 |
b. 94 |
Given that String[] str has been initialized, to get a copy of str[0] with all characters converted to upper case, use the following statement: a. str[0].upperCase(); |
c. str[0].toUpperCase(); |
The binary search algorithm: a. will cut the portion of the array being searched in half each time the loop fails to locate the search value |
a. will cut the portion of the array being searched in half each time the loop fails to locate the search value |
This ArrayList class method deletes an item from an ArrayList. a. erase |
b. remove |
Given the following two-dimensional array declaration, which statement is TRUE? int [][] numbers = new int [6] [9]; a. The array numbers has 54 rows. |
d. The array numbers has 6 rows and 9 columns. |
Each array in Java has a public field named ________ that contains the number of elements in the array. a. capacity |
d. length |
The ArrayList class is in this package. a. java.arraylist |
b. java.util |
The sequential search algorithm: a. must always be implemented as a method |
b. uses a loop to sequentially step through an array, starting with the first element |
A search algorithm: a. arranges elements in descending order |
b. is a way to locate a specific item in a larger collection of data |
By default, Java initializes array elements with what value? a. 0 |
a. 0 |
What do you normally use with a partially-filled array? a. A class that does nothing but manage the array |
d. An accompanying integer value that holds the number of items stored in the array |
If numbers is a two-dimensional int array that has been initialized and total is an int that has been set to 0, which of the following will sum all the elements in the array? a. for (int row = 1; row < numbers.length; row++) b. for (int row = 0; row < numbers.length; row++) c. for (int for = 0; numbers.length; row++) d. for (int row = 0; row < numbers[row].length; row++) |
b. for (int row = 0; row < numbers.length; row++) { for int col = 0; col < numbers[row].length; col++) total += numbers[row][col]; } |
A ragged array is: a. a two-dimensional array for which the number of rows is unknown |
c. a two-dimensional array where the rows are of different lengths |
If final int SIZE = 15 and int[] x = new int[SIZE], what would be the range of subscript values that could be used with x[]? a. 1 through 14 |
d. 0 through 14 |
This ArrayList class method is used to insert an item into an ArrayList. a. store |
d. add |
In memory, an array of String objects: a. consists of elements, each of which is a String object |
d. consists of elements, each of which is a reference to a String object |
Java Ch. 7 Quiz
Share This
Unfinished tasks keep piling up?
Let us complete them for you. Quickly and professionally.
Check Price