Verityprep
Question Bank · Unit 4

AP® Computer Science A Data Collections Practice Questions

Work through AP Computer Science A practice 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 111–120 of 1,222
  1. 111
  2. 112
  3. 113
  4. 114
  5. 115
  6. 116
  7. 117
  8. 118
  9. 119
  10. 120

Question 111

Multiple choice Arraylists
The two versions of the search method shown below are both intended to return true if ArrayList<Object> list contains the target value; otherwise they are…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 112

Multiple choice Recursion
Consider the following recursive method. public static void printSomething(int n) { if (n…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 113

Multiple choice Sorting And Searching
Consider the following method. /** Returns the index of searchVal, if found in list; * otherwise returns -1 */ public int binarySearch (ArrayList<String> list,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 114

Multiple choice 2D Arrays
int[][] t = new int[2][3]; for (int i = 0; i < t.length; i++) { for (int j = 0; j <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 115

Multiple choice Arraylists
What is the outcome when the following code is compiled/executed? ArrayList<Integer> numbers = new ArrayList<Integer>();…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 116

Multiple choice 2D Arrays
Consider the following class. public class Matrix { private int[][] m; /** Initializes m to a square n-by-n array with all * the elements on the diagonal…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 117

Multiple choice Arraylists
Consider the following code segment. ArrayList<Integer> list = new ArrayList<Integer>(); list.add(1); list.add(2); for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 118

Multiple choice Arrays
Consider the following method. public void reduce(int[] arr, int len) { for (int k = 0; k < len; k++) { arr[k]--; } len--; } What is printed when the following…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 119

Multiple choice Arraylists
How do you create an…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 120

Multiple choice Arraylists
What is a primary difference…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 111 of 1,222
Page 12 of 123