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

Questions 291–300 of 300
  1. 291
  2. 292
  3. 293
  4. 294
  5. 295
  6. 296
  7. 297
  8. 298
  9. 299
  10. 300

Question 291

Multiple choice Arrays
Consider the sorted array {2, 4, 7, 11, 15, 20, 26, 33, 41} (indices 0 through 8). A binary search is performed for the target value 20. The search uses the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 292

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 293

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 294

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 295

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 296

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 297

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 298

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 299

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 300

Multiple choice Arrays
Consider the following code segment. int[] a = {2, 4, 6}; int[] b = a; b[1] = a[0] +…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 291 of 300
Page 30 of 30