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 211–220 of 341
  1. 211
  2. 212
  3. 213
  4. 214
  5. 215
  6. 216
  7. 217
  8. 218
  9. 219
  10. 220

Question 211

Multiple choice Arrays
Consider the following method: /** * Precondition: a != null; a.length > 0 */ private static void doIt(double[] a) { for (int k = 0; k < a.length / 2; k++)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 212

Multiple choice Arrays
Consider the following class: public class ArraySorter { public static void sort(int[] arr) { for (int i = 0; i < arr.length; i++) { for (int j = arr.length -…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 213

Multiple choice Arrays
Consider the following three implementations of a method rotate90Degrees and the code segments used to test them. I. public int[] rotate90Degrees(int[] v) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 214

Multiple choice Arrays
String[] a = {"A", "B"}; String[] b = a; String[] c = {a[0], a[1]}; String letter = a[0]; a[0] = a[1]; a[1] =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 215

Multiple choice Arrays
What is the value of v[4] after the following code segment is executed? int d = 1;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 216

Multiple choice Arrays
Consider the following code segment. int[] factors = {2, 3, 4, 7, 2, 5}; int product = 1; for (int i = 1; i <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 217

Multiple choice Arrays
Consider the following incomplete method cutToAverage. public double cutToAverage(double[] amps) { double avg = 0.0; // missing code return avg; } It first…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 218

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

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 219

Multiple choice Arrays
Consider the following method: public int countSomething(int[] arr) { int m = arr[0]; int count = 1; for (int k = 1; k < arr.length; k++) { int a =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 220

Multiple choice Arrays
Consider the following method: public void change(double[] nums, int n) { for (int k = 0; k < n; k++) { nums[k] = 5.4; } n = 2; } What will be stored…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 211 of 341
Page 22 of 35