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,761–2,770 of 2,811
  1. 2761
  2. 2762
  3. 2763
  4. 2764
  5. 2765
  6. 2766
  7. 2767
  8. 2768
  9. 2769
  10. 2770

Question 2761

Multiple choice Unit 4: Data Collections
Consider the following code segment. ArrayList<Integer> list = new ArrayList<Integer>(); list.add(10); list.add(20); list.add(30);…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2762

Multiple choice Unit 4: Data Collections
Consider the following code segment. int[] arr = {3, 7, 2, 9, 5, 1, 9, 4}; int best = arr[0]; int idx = 0; for (int i = 1; i < arr.length;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2763

Multiple choice Unit 4: Data Collections
Consider the following code segment. int[][] m = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }; int sum = 0; for (int r = 0; r < m.length; r++) { for (int c = 0; c <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2764

Multiple choice Unit 4: Data Collections
A method is intended to insert target into an ArrayList<Integer> called nums immediately after the first element that is strictly greater than target. If no…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2765

Multiple choice Unit 4: Data Collections
Consider the following method.
public static int f(int n)
{
    if (n <= 1)
    {
        return n;
    }
    return n + f(n - 2);
}
What is returned by the call f(7)?
Pick an answer, then check it. The solution opens in a window.

Question 2766

Multiple choice Unit 4: Data Collections
Consider the following code segment. int[][] grid = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }; int total = 0; for (int r = 0; r < grid.length; r++) { for (int c = 0;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2767

Multiple choice Unit 4: Data Collections
Consider the following code segment. int[][] grid = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; int sum = 0; for (int r = 0; r < grid.length; r++) { for (int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2768

Multiple choice Unit 4: Data Collections
Consider the following method. public static int mystery(int n) { if (n <= 0) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2769

Multiple choice Unit 4: Data Collections
Consider using selection sort (which repeatedly finds the minimum of the unsorted portion and swaps it with the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2770

Multiple choice Unit 4: Data Collections
Consider using insertion sort (processing index i from 1 upward, inserting arr[i] into the sorted prefix arr[0..i-1]) on the array {8, 2, 6, 1, 4}. What is the array after the first three iterations (i = 1, 2, 3) of the outer loop?
Pick an answer, then check it. The solution opens in a window.
Question 2,761 of 2,811
Page 277 of 282