Verityprep
Question Bank · Unit 4

AP® Computer Science A Data Collections Multiple Choice Questions

Work through AP Computer Science A multiple-choice 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 71–80 of 145
  1. 71
  2. 72
  3. 73
  4. 74
  5. 75
  6. 76
  7. 77
  8. 78
  9. 79
  10. 80

Question 71

Multiple choice 2D Arrays
Consider the following code segment. int[][] mat = new int[3][4]; for (int row = 0; row < mat.length; row++) { for (int col = 0; col < mat[0].length; col++) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 72

Multiple choice 2D Arrays
Consider the following method that will access a square matrix mat. /** Precondition: mat is initialized and is a square matrix. */ public static void…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 73

Multiple choice 2D Arrays
Consider the following instance variable and methods in the same class. private int[][] matrix; /** Precondition: array.length > 0. * @return the largest…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 74

Multiple choice 2D Arrays
Consider method1 and method2 below, which are identical except for the second last line of code. Each method returns a new matrix based on the input matrix mat.…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 75

Multiple choice 2D Arrays
Consider the following instance variables and method assignValues in the same class. private int numRows; private int numCols; private int[][] mat; /** arr has…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 76

Multiple choice 2D Arrays
A two-dimensional matrix mat with at least one row is initialized and will be traversed using…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 77

Multiple choice 2D Arrays
A square matrix is declared as int[][] mat = new int[SIZE][SIZE]; where SIZE is an appropriate integer constant. Consider the following method. public static…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 78

Multiple choice 2D Arrays
A matrix class that manipulates matrices contains the following declaration. private int[][] mat = new int[numRows][numCols]; Consider the following method that…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 79

Multiple choice 2D Arrays
Consider the following code segment. int[][] mat = {{3,4,5}, {6,7,8}}; int sum = 0; for (int[] arr: mat) { for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 80

Multiple choice 2D Arrays
A matrix (two-dimensional array) is declared as int[][] mat = new int[2][3]; Consider the following method. public static void changeMatrix(int[][] mat) { for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 71 of 145
Page 8 of 15