Java 2 Chapter 8 review study
An array is a list of data items that all _________________.
have the same type
When you declare an array, _________________.
you might reserve memory for it in the same statement
For how many integers does the following statement reserve room?
int[] values = new int[34];
34
Which of the following can be used as an array subscript?
int
If you declare an array as follows, how do you indicate the final element of the array?
int[] nums = new int[6];
nums[5]
If you declare an integer array as follows, what is the value of nums[2]?
int[] nums = {101, 202, 303, 404, 505, 606};
303
When you initialize an array by giving it values upon creation, you _________________.
do not explicitly give the array a size
In Java, you can declare an array of 12 elements and initialize _________________.
all of them
Assume x is an integer and an array is declared as follows. Which of the following statements correctly assigns the value 100 to each of the array elements?
int[] nums = new int[4];
for(x = 0; x < 4; ++x) nums[x] = 100;
uppose you have declared an array as follows:
int[] creditScores = {670, 720, 815};
What is the value of creditScores.length?
3
A parallel array is one that _________________.
holds values that correspond to those in another array
When you pass an array element to a method, the method receives _________________.
a copy of the value in the element
A single array element of a primitive type is passed to a method by _________________.
value
When you pass an array to a method, the method receives _________________.
the address of the array
When you place objects in order beginning with the object with the highest value, you are sorting in _________________ order.
descending
Using a bubble sort involves comparing each array element with _________________.
the adjacent element
The following defines a _________________ array:
int[][] nums = { {1, 2}, {3, 4}, {5, 6} };
two-dimensional
How many rows are contained in the following array?
double[] [] prices = {{2.56,3.57,4.58,5.59},{12.35,13.35,14.35,15.00}};
2
In the following array, what is the value of codes[2][1]?
char[] [] codes = {'A','D','M'},{'P','R','S'},{'U','V','Z'};
'V'
The methods in the Arrays class _________________.
are static methods