# 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 = "S";
• The code letterGrid = "S"; actually sets the 1st row and 3rd column to hold a reference to the String object "S".
• (B) strGrid = "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 = "S";
• This would be true if row and column indicies started at 1 instead of 0.
• (D) strGrid = "S";
• In row-major order the row is specified first followed by the column. Row and column indicies start with 0. So letterGrid is the 3rd row and 1st column.
• (E) strGrid = "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
• This would be true if the row index started at 0, but the column index started at 1.
• (B) a
• Both the row and column indicies start with 0.
• (C) a
• The value 6 is at row 0 and column 2.
• (D) a
• The row index is specified first, then the column index.
• (E) a
• The row index is specified first and the indicies start at 0.
Next Section - Medium Multiple Choice Questions