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.

Questions 11–20 of 1,222
  1. 11
  2. 12
  3. 13
  4. 14
  5. 15
  6. 16
  7. 17
  8. 18
  9. 19
  10. 20

Question 11

Multiple choice 2D Arrays
Consider the following code segment. String[][] letters = {{"A", "B", "C", "D"}, {"E", "F", "G", "H"}, {"I", "J", "K", "L"}}; for (int col = 1; col <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 12

Multiple choice Arraylists
The following method is intended to remove all elements of an ArrayList of integers that are divisible by key and add the removed elements to a new ArrayList,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 13

Multiple choice Arrays
Consider the mode method, which is intended to return the most frequently occurring value (mode) in its int[] parameter arr. For example, if the parameter of…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 14

Multiple choice Arraylists
Consider the following class definition. public class Value { private int num; public int getNum() { return num; } // There may be instance variables,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 15

Multiple choice Recursion
Consider the following recursive method. public static boolean recurMethod(String str) { if (str.length() <= 1) { return true; } else if (str.substring(0,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 16

Multiple choice Arrays
Consider the following instance variable and method. private int[] arr; /** Precondition: arr.length > 0 * @return the largest value in array arr */ public int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 17

Multiple choice 2D Arrays
Consider the following method. public static int[] operation(int[][] matrix, int r, int c) { int[] result = new int[matrix.length]; for (int j = 0 ; j <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 18

Multiple choice Arrays
Consider the following instance variable and method. private int[] numbers; public void mystery(int x) { for (int k = 1; k < numbers.length; k = k + x) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 19

Multiple choice Recursion
Consider the following method. public static void showMe(int arg) { if (arg < 10) { showMe(arg +…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 20

Multiple choice 2D Arrays
Consider the following method. /** Precondition: values has at least one row */ public static int calculate(int[][] values) { int found = values[0][0]; int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 11 of 1,222
Page 2 of 123