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.

Questions 1,051–1,060 of 1,079
  1. 1051
  2. 1052
  3. 1053
  4. 1054
  5. 1055
  6. 1056
  7. 1057
  8. 1058
  9. 1059
  10. 1060

Question 1051

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

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1052

Multiple choice 2D Arrays
Consider the following array declaration. int[][] m = { {1, 2, 3}, {4, 5, 6},…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1053

Multiple choice Recursion
Consider the following method. public static int f(int n) { if (n < 10)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1054

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 1055

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 1056

Multiple choice Arraylists
Consider the following code segment. ArrayList<String> list = new ArrayList<String>(); list.add("A");…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1057

Multiple choice 2D Arrays
Consider the following code segment. int[][] m = { {1, 2, 3}, {4, 5, 6} }; int[][] r = new int[m[0].length][m.length]; for (int i = 0; i <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1058

Multiple choice Recursion
Consider the following method.
public static int g(int n)
{
    if (n == 1)
        return 1;
    if (n % 2 == 0)
        return g(n / 2);
    return 1 + g(n - 1);
}
What value is returned by g(12) ?
Pick an answer, then check it. The solution opens in a window.

Question 1059

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 1060

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 1,051 of 1,079
Page 106 of 108