AP Computer Science A Unit 8 Progress
Check: MCQ Study 2023
A two-dimensional array myArray is to be created with the following contents.
{{0, 0, 3},
{0, 0, 0},
{7, 0, 0}}
Which of the following code segments can be used to correctly create and initialize myArray ?int myArray[][] = new int[3][3];myArray[0][2] = 3;myArray[2][0] = 7; int myArray[][] = new int[3][3];myArray[0][2] = 7;myArray[2][0] = 3; int myArray[][] = {{0, 0, 3}, {0, 0, 0}, {7, 0, 0}}; - ANSWER D) I and III Consider the following code segment, which is intended to create and initialize the two- dimensional (2D) integer array num so that columns with an even index will contain only even integers and columns with an odd index will contain only odd integers.int[][] num = /* missing code */; Which of the following initializer lists could replace /* missing code */ so that the code segment will work as intended? - ANSWER A) {{0, 1, 2}, {4, 5, 6}, {8, 3, 6}} Consider the following code segment, which is intended to display "cat".String[][] keyboard = {{"q", "w", "e", "r", "t"}, {"a", "s", "d", "f", "g"}, {"z", "x", "c", "v", "b"}}; System.out.println(/* missing expression */); Which of the following can replace /* missing expression */ so that the code segment works as intended? - ANSWER C) keyboard[2][2] + keyboard[1][0] + keyboard[0][4] Consider the following code segment, where twoD is a two-dimensional (2D) String array. The code segment is intended to display "JAVA".System.out.print(twoD[2][1]); System.out.print(twoD[3][2]); System.out.print(twoD[1][1]); Which of the following code segments properly declares and initializes twoD so that the code segment works as intended? - ANSWER A) String[][] twoD = {{"V", "AV", "J"}, {"JA", "VA", "A"}, {"JA", "J", "JAV"}, {"AV", "V", "A"}}; Consider the following code segment.int[][] multi = new int[4][4]; for (int rows = 0; rows < 4; rows++) {
- / 1