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 121–130 of 195
  1. 121
  2. 122
  3. 123
  4. 124
  5. 125
  6. 126
  7. 127
  8. 128
  9. 129
  10. 130

Question 121

Free response 2D Arrays
A telescope scans a rectangular area of the night sky and collects the data into a 1-dimensional array. Each data value scanned is a number representing the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 122

Free response 2D Arrays
This question involves reasoning about a two-dimensional (2D) array of integers. You will write two static methods, both of which are in a single enclosing…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 123

Free response 2D Arrays
This question involves pieces of candy in a box. The Candy class represents a single piece of candy. public class Candy { / * * Returns a String representing…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 124

Free response 2D Arrays
This question involves manipulation of one-dimensional and two-dimensional arrays. In part (a), you will write a method to shift the elements of a…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 125

Multiple choice 2D Arrays
public class FrequentFlyer { private int miles = 0; public FrequentFlyer(int m) { miles = m; } public void addMiles(int m) { miles += m;} public int getMiles()…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 126

Free response 2D Arrays
Highway is a rectangular nonempty int matrix: rows are lanes, columns are positions. A1 is a car and a0 an empty position. Cars move right; forward movement…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 127

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 128

Free response 2D Arrays
In chess, a queen can move vertically, horizontally, and diagonally on an 8-by-8 chessboard. The picture below shows all the positions on the board that a queen…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 129

Free response 2D Arrays
SmartParkingSimulator uses a rectangular boolean matrix: true means occupied, false available. Choose the first row from top to bottom with any vacancy; within…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 130

Multiple choice 2D Arrays
Consider the following code segment: int[][] num = new int[4][4]; for (int i = 0; i < num.length; i++) { for (int k…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 121 of 195
Page 13 of 20