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 31–40 of 1,079
  1. 31
  2. 32
  3. 33
  4. 34
  5. 35
  6. 36
  7. 37
  8. 38
  9. 39
  10. 40

Question 31

Multiple choice Sorting And Searching
Questions refer to the following information. Consider the following binarySearch method. The method correctly performs a binary search. /** Precondition: data…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 32

Multiple choice Sorting And Searching
Suppose the binarySearch method is called with an array containing 2,000 elements sorted in increasing…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 33

Multiple choice Arrays
Consider the following incomplete method that is intended to return a string formed by concatenating elements from the parameter words. The elements to be…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 34

Multiple choice Recursion
Consider the following method. /** Precondition: 0 < numVals <= nums.length */ public static int mystery(int[] nums, int v, int numVals) { int k = 0; if (v ==…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 35

Multiple choice Arraylists
Consider the following code segment. List<String> students = new ArrayList<String>(); students.add("Alex"); students.add("Bob"); students.add("Carl"); for (int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 36

Multiple choice Arrays
Assume that an array of integer values has been declared as follows and has been initialized. int[] arr =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 37

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

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 38

Multiple choice Arrays
Consider the following instance variable and incomplete method. The method calcTotal is intended to return the sum of all values in vals. private int[] vals;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 39

Multiple choice Arraylists
Consider the following method that is intended to modify its parameter nameList by replacing all occurrences of name with newValue. public void…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 40

Multiple choice Recursion
Consider the following method. // precondition: x >= 0 public void mystery(int x) { if ((x / 10) != 0) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 31 of 1,079
Page 4 of 108