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 311–320 of 1,222
  1. 311
  2. 312
  3. 313
  4. 314
  5. 315
  6. 316
  7. 317
  8. 318
  9. 319
  10. 320

Question 311

Multiple choice Arrays
In the following code segment, assume that the string str has been properly declared and initialized. The code segment is intended to print the number of…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 312

Multiple choice Arrays
Consider an integer array, nums, which has been declared and initialized with one or more integer values. Which of the following code segments updates nums so…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 313

Multiple choice Arraylists
Consider the following code segment. ArrayList<String> numbers = new ArrayList<String>(); numbers.add("one"); numbers.add("two"); numbers.add(0, "three");…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 314

Multiple choice Arraylists
Consider the following method, which is intended to return a list containing the elements of the parameter myList with all even elements removed. public static…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 315

Multiple choice 2D Arrays
Consider the following code segment. int[][] points = {{11, 12, 13, 14, 15}, {21, 22, 23, 24, 25}, {31, 32, 33, 34, 35}, {41, 42, 43, 44, 45}}; for (int row =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 316

Multiple choice 2D Arrays
Consider the following code segment. int[][] arr = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}; int sum = 0; for (int[] x :…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 317

Multiple choice Arrays
Consider the following code segment. int[] arr = {4, 2, 2, 3, 1}; int num = 0; for (int k = 0;k…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 318

Multiple choice Arraylists
Consider the following method, which is intended to print the ArrayList names in reverse order. public static void printInReverseOrder(ArrayList<String> names)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 319

Multiple choice Recursion
Consider the following method. public static int calc(int n) { if (n == 0) { return 0; }…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 320

Multiple choice 2D Arrays
Consider the following code segment. int[][] rectangle = new int[4][5]; / * some statements not shown * / x = rectangle[0]; Assume that x has been previously…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 311 of 1,222
Page 32 of 123