Image From Wikibooks.
Β
βSTOP!β Before you look at the answers make sure you gave this practice quiz a try so you can assess your understanding of the concepts covered in unit 8. Click here for the practice questions:
AP CS8 Unit # Multiple Choice Questions.Facts about the test: The AP Computer Science A exam has 40 multiple choice questions and you will be given 90 minutes to complete the section. That means it should take you around 34 minutes to complete 15 questions.
*The following questions were not written by CollegeBoard and although they cover information outlined in the AP Computer Science A Course and Exam Description the formatting on the exam may be different.
A. int[][] arrayRectangle = new int[][];
B. int[][] arrayRectangle = new String[5][4];
C. int[][] arrayRectangle = new int[5][4];
D. int arrayRectangle[][] = new int[5][4];
Answer:Β proper syntax
π
Study AP CSA, Unit 8.1: 2D Arrays
A. 8
B. 9
C. 10
D. 46
Answer:Β The printed line is row 4, column 6, which was set to a value of row+col-1 in the nested for loop. In this case it is 4+6-1, equaling 9.Β
πΒ
Study AP CSA, Unit 8.2:Β Traversing 2D Arrays
A. "Daniel"
B. "Taylor"
C. "Fletcher"
D. "Amir"
Answer:Β The elements start at index 0, and the first value [3] represents the row and the second value [2] represents the column. Therefore row 3+1=4 down and column 2+1=3 across, which is "Daniel".
πΒ
Study AP CSA, Unit 8.1:Β 2D Arrays
A. 3
B. 4
C. 5
D. 6
Answer:Β int i represents rows and int j represents columns. Since j is set to 2, and the index starts from 0, all values will be in the last column that has values of 1, 3, and 1. However, in the for loop, i is only incremented to where it is less than arrayTwo.length - 1, which would be 2. In the first iteration, arrayTwo[0][2] is 1. In the second iteration, arrayTwo[1][2] is 3. There are no more iterations after that, meaning that total = 1+3=4.Β
πΒ
Study AP CSA, Unit 8.2:Β Traversing 2D Arrays
A. [1][3], [0][1], [2][2]
B. [2][4], [1][2], [3][3]
C. [3][1], [1][0], [2][2]
D. [4][2], [2][1], [3][3]
Answer:Β Since Java is a zero-indexed language, all indexes start from 0. The first value is the row, and the second value is the column. So apple has a row index of 1 and a column index of 3: [1][3]. Grapefruit has a row index of 0 and a column index of 1: [0][1]. Cherries has a row index of 2 and a column index of 2: [2][2].Β
πΒ
Study AP CSA, Unit 8.1:Β 2D Arrays
A. The number of rows and columns averaged
B. The number of columns
C. The number of rows and columns
D. The number of rows
Answer:Β knowledge about 2D arrays
πΒ
Study AP CSA, Unit 8.1:Β 2D Arrays
A. NullPointerException
B. InterruptedException
C. ArrayIndexOutOfBoundsException
D. Runtime Exception
Answer:Β definition and using <= in the for loop for length when index starts at 0
πΒ
Study AP CSA, Unit 8.1:Β 2D Arrays
A. row < arrayFour.length()
B. arrayFour[0].length
C. row <= arrayFour.length()
D. arrayFour[].length
Answer:Β definition of 2D array; length is not called as a method but as a variable
πΒ
Study AP CSA, Unit 8.1:Β 2D Arrays
A. row-wise traversal, row-wise traversal
B. row-wise traversal, column-wise traversal
C. column-wise traversal, row-wise traversal
D. column-wise traversal, column-wise traversal
Answer: definition
πΒ
Study AP CSA, Unit 8.2:Β Traversing 2D Arrays
A. {{"#", "#', "#", "$", "#"}, {"#", "#", "#", "S", "#"}}
B. {{"#", "#', "#", "$"}, {"#", "#", "S", "#"}}
C. {{"$", "#', "#", "$", "#"}, {"$", "#", "#", "S", "#"}}
D. {{"$", "#', "#", "$"}, {"$", "#", "#", "S"}}
Answer: The 2D array is 2x4, so row indexes go from 0 to 1 and column indexes go from 0 to 3. 0 % 3 is still 0, so the first values of both rows are "$". 3%3 is also 0, so the value at index 3 is also "$".Β
πΒ
Study AP CSA, Unit 8.1:Β 2D Arrays
A. [row][column]
B. [column][row]
C. [size][column]
D. [column][length]
Answer: definition
πΒ
Study AP CSA, Unit 8.1:Β 2D Arrays
A. No
B. Yes
C. Only int arrays
D. Only String arrays
Answer: definition
πΒ
Study AP CSA, Unit 8.1:Β 2D Arrays
A. All values are defaulted to 0.0
B. All values are defaulted to null
C. It depends on the type of value and isn't the same for all
D. All values are defaulted to false
Answer: definition; given that 2D arrays can be comprised of any types including objects
πΒ
Study AP CSA, Unit 8.1:Β 2D Arrays
A. I
B. III
C. I, III
D. I, II, III
Answer: I has no errors as it is a typical nested loop traversing through a 2D array. III also has no errors being a typical enhanced nested loop traversing through a 2D array. II has errors in that it has a type mismatch: cannot convert from element type int[] to int[][].Β
πΒ
Study AP CSA, Unit 8.2:Β Traversing 2D Arrays
A.Β
B.Β
C.Β
D.Β
Answer: B. Definition, as index starts from 0, while length starts from 1, therefore to find the last element of the last row, that would be the last index, so the length-1 for both rows and columns.
πΒ
Study AP CSA, Unit 8.1:Β 2D Arraysπ¦ Jump to AP CSA Unit 9 Multiple Choice Questions
π€ Connect with other students studying AP CSA with
Hours