# 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}};?
• (A) 2
• The size of outer array is the number of rows. Remember that two-dimensional arrays are actually an array of arrays in Java.
• (B) 4
• The size of the inner array is the number of columns.
• (C) 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).
• (A) 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".
• (B) 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.
• (C) strGrid[3][1] = "S";
• This would be true if row and column indicies started at 1 instead of 0.
• (D) 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.
• (E) 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) a[0][3]
• This would be true if the row index started at 0, but the column index started at 1.
• (B) a[1][3]
• (C) a[0][2]
• The value 6 is at row 0 and column 2.
• (D) a[2][0]
• The row index is specified first, then the column index.
• (E) a[3][1]
• The row index is specified first and the indicies start at 0.
Next Section - Medium Multiple Choice Questions