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

Question 121

Multiple choice Arrays
Rearrange so every 4 is immediately followed by 5, without moving4s. Counts match; each 4 has a non4 successor. Fives may originally appear anywhere. Which…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 122

Multiple choice Arrays
For a nonempty array, test whether it can be split between elements into two nonempty parts of equal sum. Sums fit in int. Which replacement for /* missing */…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 123

Multiple choice Arrays
outer is sorted in nondecreasing order and inner in strictly increasing order. Return true if all inner values occur in outer, using one linear scan. Which…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 124

Multiple choice Arrays
For n≥0 with n*n fitting in int, create n groups of length n: group1 ends in1, group2 in2,1, and so on; earlier positions are0. Which replacement for /* missing…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 125

Multiple choice Arrays
For n≥0 and a result length fitting in int, concatenate groups [1],[1,2],...,[1,..., n]. Which replacement for /* missing */ makes the method meet its…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 126

Multiple choice Arrays
Return the length of the largest contiguous section appearing somewhere in reverse order; overlap is allowed. Which replacement for /* missing */ makes the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 127

Multiple choice Arrays
A clump is a maximal run of at least two equal adjacent values. Return the clump count. Which replacement for /* missing */ makes the method meet its…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 128

Multiple choice Arrays
In the following code segment, assume that the string str has been properly declared and initialized. The code segment is intended to print the number of…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 129

Multiple choice Arrays
Consider an integer array, nums, which has been declared and initialized with one or more integer values. Which of the following code segments updates nums so…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 130

Multiple choice Arrays
Consider the following code segment. int[] arr = {4, 2, 2, 3, 1}; int num = 0; for (int k = 0;k…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 121 of 300
Page 13 of 30