# 10.12. Easy Multiple Choice Questions¶

These problems are easier than most of those that you will usually see on the AP CS A exam.

9-7-1: How many columns does a have if it is created as follows int[][] a = {{2, 4, 6, 8}, {1, 2, 3, 4}};?
• 2
• The size of outer array is the number of rows. Remember that two-dimensional arrays are actually an array of arrays in Java.
• 4
• The size of the inner array is the number of columns.
• 8
• This is the total number of items in the array.

You can see how the array looks by clicking on the following Ex-9-7-1.

9-7-2: Which of the following statements assigns the letter S to the third row and first column of a two-dimensional array named strGrid (assuming row-major order).
• strGrid[0][2] = "S";
• The code letterGrid[0][2] = "S"; actually sets the 1st row and 3rd column to hold a reference to the String object "S".
• strGrid[1][3] = "S";
• This would be true if row and column indicies started at 1 instead of 0 and if this was in column major order.
• strGrid[3][1] = "S";
• This would be true if row and column indicies started at 1 instead of 0.
• strGrid[2][0] = "S";
• In row-major order the row is specified first followed by the column. Row and column indicies start with 0. So letterGrid[2][0] is the 3rd row and 1st column.
• strGrid[0][0] = "S";
• This would set the element at the first row and column.
9-7-3: How would you get the value 6 out of the following array int[][] a = {{2, 4, 6, 8}, {1, 2, 3, 4}};?
• a[0][3]
• This would be true if the row index started at 0, but the column index started at 1.
• a[1][3]