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,791–2,800 of 2,811
  1. 2791
  2. 2792
  3. 2793
  4. 2794
  5. 2795
  6. 2796
  7. 2797
  8. 2798
  9. 2799
  10. 2800

Question 2791

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

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

Multiple choice Unit 4: Data Collections
Consider the following code segment.
ArrayList<Integer> values = new ArrayList<Integer>();
values.add(2);
values.add(5);
values.add(1);
values.add(5);

for (int i = values.size() - 1; i >= 0; i--)
{
    if (values.get(i) == 5)
        values.remove(i);
}

System.out.println(values);
What is printed?
Pick an answer, then check it. The solution opens in a window.

Question 2794

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;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2795

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

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2796

Multiple choice Unit 4: Data Collections
Suppose arr is declared and initialized as follows. int[] arr = {7, 3, 9, 2, 5}; After one pass of selection sort that…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2797

Multiple choice Unit 4: Data Collections
Suppose arr is declared and initialized as follows. int[] arr = {8, 4, 6, 3, 7}; After the first three passes of insertion sort…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2798

Multiple choice Unit 4: Data Collections
Suppose a standard binary search is used to locate 12 in the following sorted array.…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2799

Multiple choice Unit 4: Data Collections
A text file contains the following integers, separated by spaces. 6 2 9 3 8 Assume sc is a properly constructed Scanner that reads the file. What is printed by…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2800

Multiple choice Unit 4: Data Collections
Consider the following class. public class ScoreEntry { private String name; private int score; public ScoreEntry(String n, int s) { name = n; score = s; }…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 2,791 of 2,811
Page 280 of 282