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 101–110 of 195
  1. 101
  2. 102
  3. 103
  4. 104
  5. 105
  6. 106
  7. 107
  8. 108
  9. 109
  10. 110

Question 101

Multiple choice 2D Arrays
Consider the following class definition: public class Matrix { private int[][] data; public Matrix(int rows, int cols) { data = new int[rows][cols]; } public…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 102

Multiple choice 2D Arrays
A grayscale image is stored in a 2D array of integers called image. Each element represents a pixel's brightness value, ranging from 0 (black) to 255 (white).…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 103

Multiple choice 2D Arrays
Consider the following code segment: for (int r = 1;r < mat.length;r++) { for (int c = 1;c < mat[0].length;c++) { if ((r + c) % 2 == 0) mat[r][c] = 2 * mat[r -…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 104

Multiple choice 2D Arrays
Which of the following code segments correctly…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 105

Free response 2D Arrays
In a traffic modeling application, a segment of a highway is represented as a two-dimensional array of integers, in which each row represents one lane and each…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 106

Multiple choice 2D Arrays
Suppose m is a two-dimensional array of size 4 by 4, with all its elements initialized to zeros. The method fill is defined as follows: public void…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 107

Free response 2D Arrays
Seats in a movie theater are modeled by a two-dimensional array of boolean values: true represents an occupied seat and false represents a vacant seat. Row…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 108

Free response 2D Arrays
A crossword puzzle grid is a two-dimensional rectangular array of black and white squares. Some of the white squares are labeled with a positive number…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 109

Multiple choice 2D Arrays
Given the following method, 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 110

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 101 of 195
Page 11 of 20