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: Arrays Clear filter

Questions 311–320 of 341
  1. 311
  2. 312
  3. 313
  4. 314
  5. 315
  6. 316
  7. 317
  8. 318
  9. 319
  10. 320

Question 311

Free response Arrays
A hardware store tracks how many units of a particular item are in stock at the end of each day. The class StockLog stores these daily counts in the array…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 312

Multiple choice Arrays
Consider the following code segment, where data is a non-empty int array containing only positive values terminated by a single -1 sentinel that appears…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 313

Multiple choice Arrays
Consider the following class. public class Stack3 { private int[] data; private int top; public Stack3() { data = new int[3]; top = 0; } public boolean push(int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 314

Multiple choice Arrays
Consider an int array a initially equal to {40, 12, 25, 7, 31, 18}. Insertion sort, sorting in ascending order, treats the prefix of length k as already sorted…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 315

Free response Arrays
A weather station records the rainfall, in millimetres, that fell during each day of an observation period. The class RainfallLog stores these daily…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 316

Multiple choice Arrays
Consider the following code segment. int[] a = {4, 7, 2, 9, 5}; int sum = 0; for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 317

Multiple choice Arrays
Consider the following code segment, which uses binary search on a sorted array. int[] a = {2, 5, 8, 11, 14, 17, 20, 23, 26, 29}; int low = 0; int high =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 318

Multiple choice Arrays
Consider the following method. public static int countMatches(int[] a, int[] b) { int count = 0; for (int i = 0; i < a.length; i++) { if (a[i]…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 319

Multiple choice Arrays
Consider the following code segment. int[] a = {7, 3, 9, 1, 5}; for (int i = 1; i < 4; i++) { int key = a[i]; int j = i - 1;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 320

Multiple choice Arrays
Consider the following code segment. int[] nums = {4, 1, 6, 3, 8}; int total = 0; for (int i = 0; i < nums.length - 1; i++) { if…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 311 of 341
Page 32 of 35