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,061–1,070 of 1,079
  1. 1061
  2. 1062
  3. 1063
  4. 1064
  5. 1065
  6. 1066
  7. 1067
  8. 1068
  9. 1069
  10. 1070

Question 1061

Multiple choice Arraylists
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 1062

Multiple choice 2D Arrays
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 1063

Multiple choice Recursion
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 1064

Multiple choice Sorting and Searching
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 1065

Multiple choice Sorting and Searching
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 1066

Multiple choice Sorting and Searching
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 1067

Multiple choice Using Text Files
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 1068

Multiple choice Using Text Files
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 1069

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

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1070

Multiple choice Arrays
Consider the following code segment. int[] a = {2, 4, 6}; int[] b = a; b[1] = a[0] +…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1,061 of 1,079
Page 107 of 108