1. A one-dimensional array can be thought to have a ___________________.
2. A two-dimensional (2D) array has rows and columns. A 2D array in Java is actually ______________________.
3. Arrays in Java can store many items of ____________.
4. The following 2D array (image) could be stored in a one dimensional array. Some languages store data in row-major order or column-major order. What example is shown below?
5. In Java, each element of the outer array has a reference to each inner array. In the following example the array indices start at _______________________.
6. In the following example, list all the values in the column at index 1.
7. In the following example, what value is held at row index 2 and column index 1?
8. In the above example, the value at row index 1 and column index 1 is 5.
9. The code below creates a 2D array with 2 rows and 3 columns named trackerInfo. How many elements are in trackerInfo?
10. Analyse the following code carefully. What is the output?
11. When arrays are created their contents are automatically initialized to 0 for numeric types, null for object references, and _______ for type boolean.
12. nums[2][1] = 5; would set the value for the 3rd row and 2nd column of a 2D array called nums.
13. What is the value at creationInfo[2][1] after the code below executes?
int[][] trackerInfo = { {25,20,25}, {25,20,25} };
String[][] creationInfo =
{ {"Adam", "Eve"}, {"Cain", "Abel"}, {"Seth", "Enoch"} };
Cain
Seth
Adam
Enoch
14. What is the value of name after the code below executes?
int[][] trackerInfo = { {25,20,25}, {25,20,25} };
String[][] creationInfo =
{ {"Adam", "Eve"}, {"Cain", "Abel"}, {"Seth", "Enoch"} };
int value = trackerInfo[1][0];
String name = creationInfo[0][1];
15. Given the following, what is the value of things[2].length ?
16. Which of the following constructs and assigns to array a 2D array with 7 rows, but does not yet construct the rows?
17. Given the following, which of the following statements constructs an array with 5 rows of 7 columns each and assign its reference to stuff ?
18. Examine the following. What is in values[3][0] ?
19. The square brackets [row][col] are used to access and modify an element in a 2D array.
20. 2D array objects that are not rectangular are called ragged arrays. (Note these are generally outside the scope of the AP exam)