Verityprep
Question Bank · Unit 4

AP® Computer Science A Data Collections Practice Questions

Work through AP Computer Science A practice questions on Data Collections, then check each answer against a worked solution.

Free · no sign-up Open questions need no account. Sign up or log in to open the rest.

Subtopic: 2D Arrays Clear filter

Questions 1–10 of 195
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10

Question 1

Multiple choice 2D Arrays
Consider the following code segment. int[][] values = {{1, 2, 3}, {4, 5, 6}}; int x = 0; for (int j = 0; j < values.length; j++) { for (int k = 0;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2

Multiple choice 2D Arrays
Consider the following method, which is intended to print the values in its two-dimensional integer array parameter in row-major order. public static void…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 3

Multiple choice 2D Arrays
Consider the following code segment. String[][] letters = {{"A", "B", "C", "D"}, {"E", "F", "G", "H"}, {"I", "J", "K", "L"}}; for (int col = 1; col <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 4

Multiple choice 2D Arrays
Consider the following method. public static int[] operation(int[][] matrix, int r, int c) { int[] result = new int[matrix.length]; for (int j = 0 ; j <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 5

Multiple choice 2D Arrays
Consider the following method. /** Precondition: values has at least one row */ public static int calculate(int[][] values) { int found = values[0][0]; int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 6

Multiple choice 2D Arrays
Consider the following definition. int[][] numbers = {{1, 2, 3}, {4, 5,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 7

Multiple choice 2D Arrays
Consider the following code segment. String[][] board = new String[5][5]; for (int row = 0; row < 5; row++) { for (int col = 0; col < 5; col++) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 8

Multiple choice 2D Arrays
Consider the following method. Method allEven is intended to return true if all elements in array arr are even numbers; otherwise, it should return false.…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 9

Multiple choice 2D Arrays
Given the following method and what would the result be when m is executed? public void m(int[][]p) { int height = p.length; for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 10

Multiple choice 2D Arrays
A two-dimensional array is used to represent a matrix. The declaration is below: private int[][] matrix = new int[2][3]; public static void changeMatrix(int[][]…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1 of 195
Page 1 of 20