Verityprep
Question Bank

AP® Computer Science A Multiple Choice Questions

Work through AP Computer Science A multiple-choice questions unit by unit, 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 2,781–2,790 of 2,811
  1. 2781
  2. 2782
  3. 2783
  4. 2784
  5. 2785
  6. 2786
  7. 2787
  8. 2788
  9. 2789
  10. 2790

Question 2781

Multiple choice Unit 4: Data Collections
Consider the following class. public class Reading { private String sensor; private double value; public Reading(String s, double v) { sensor = s; value = v; }…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2782

Multiple choice Unit 4: Data Collections
Consider the following code segment. int[] a = {4, 7, 2, 9, 5}; int sum = 0; for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2783

Multiple choice Unit 4: Data Collections
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 2784

Multiple choice Unit 4: Data Collections
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 2785

Multiple choice Unit 4: Data Collections
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 2786

Multiple choice Unit 4: Data Collections
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 2787

Multiple choice Unit 4: Data Collections
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 2788

Multiple choice Unit 4: Data Collections
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 2789

Multiple choice Unit 4: Data Collections
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 2790

Multiple choice Unit 4: Data Collections
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 2,781 of 2,811
Page 279 of 282