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 21–30 of 1,222
  1. 21
  2. 22
  3. 23
  4. 24
  5. 25
  6. 26
  7. 27
  8. 28
  9. 29
  10. 30

Question 21

Multiple choice Arrays
Consider the following method. /** Precondition: arr.length > 0 */ public static int mystery(int[] arr) { int index = 0; int count = 0; int m = -1; for (int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 22

Multiple choice Recursion
Consider the following recursive method. public static void whatsItDo(String str) { int len = str.length(); if (len > 1) { String temp…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 23

Multiple choice 2D Arrays
Consider the following definition. int[][] numbers = {{1, 2, 3}, {4, 5,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 24

Multiple choice Sorting And Searching
Consider the following code segment from an insertion sort program. for (int j = 1; j < arr.length; j++) { int insertItem = arr[j]; int k = j - 1; while (k >= 0…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 25

Multiple choice Sorting And Searching
Questions refer to the following information. Consider the following sort method. This method correctly sorts the elements of array data into increasing order.…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 26

Multiple choice Sorting And Searching
Consider the following sort method. This method correctly sorts the elements of array data into increasing order. public static void sort(int[] data) { for (int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 27

Multiple choice Recursion
Consider the following recursive method. /** Precondition: num >= 0 */ public static int what(int num) { if (num < 10) { return 1; } else { return 1 + what(num…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 28

Multiple choice 2D Arrays
Consider the following code segment. String[][] board = new String[5][5]; for (int row = 0; row < 5; row++) { for (int col = 0; col < 5; col++) {…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 29

Multiple choice Arrays
Consider the problem of finding the maximum value in an array of integers. The following code segments are proposed solutions to the problem. Assume that the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 30

Multiple choice Arraylists
Consider the following instance variable and method. Method wordsWithCommas is intended to return a string containing all the words in listOfWords separated by…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 21 of 1,222
Page 3 of 123