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 1–10 of 1,222
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10

Question 1

Multiple choice Arraylists
Consider the following code segment. ArrayList<Integer> numList = new ArrayList<Integer>(); numList.add(3);…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2

Multiple choice Recursion
Consider the following recursive method. public static void stars(int num) { if (num == 1) { return; } stars(num - 1); for (int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 3

Multiple choice Arrays
Consider the following method, which is intended to return the number of local maximum values in an array. Local maximum values are array elements that are…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 4

Multiple choice 2D Arrays
Consider the following code segment. int[][] values = {{1, 2, 3}, {4, 5, 6}}; int x = 0; for (int j = 0; j < values.length; j++) { for (int k = 0;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 5

Multiple choice Arrays
Consider the following class definition. public class Book { private int pages; public int getPages() { return pages; } // There may be instance variables,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 6

Multiple choice Arrays
Consider the following method. public static String[] strArrMethod(String[] arr) { String[] result = new String[arr.length]; for (int j = 0; j < arr.length;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 7

Multiple choice Arrays
Consider the following method. public static String[] strArrMethod(String[] arr) { String[] result = new String[arr.length]; for (int j = 0; j < arr.length;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 8

Multiple choice 2D Arrays
Consider the following method, which is intended to print the values in its two-dimensional integer array parameter in row-major order. public static void…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 9

Multiple choice Recursion
Consider the following method. public static int calcMethod(int num) { if (num == 0) { return 10;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 10

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

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1 of 1,222
Page 1 of 123