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 701–710 of 1,222
  1. 701
  2. 702
  3. 703
  4. 704
  5. 705
  6. 706
  7. 707
  8. 708
  9. 709
  10. 710

Question 701

Multiple choice Arrays
Given the following method: boolean temp = false; int count = 0; for (int testval : a) { if (testval == val) count++; } temp…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 702

Multiple choice Sorting And Searching
Given the following partial implementation of a sorting algorithm: public static void sort(int[] a) { int maxCompare = a.length - 1; int savedIndex = 0; int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 703

Multiple choice 2D Arrays
Given the following 2D array declaration and initialization: int[][] matrix = {{-1, -2, 3}, {4, -5, 6}}; And the method: public static void changeMatrix(int[][]…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 704

Multiple choice Recursion
Consider the following recursive method: public static int mystery(int n) { if (n == 0)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 705

Multiple choice Sorting And Searching
Given the initial array: {6, 3, 8, 5, 1} Which of the following correctly shows…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 706

Multiple choice Recursion
Given the following recursive method: public static int mystery(String str) { if (str.length() == 0) return 0; else { if (str.substring(0,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 707

Multiple choice Sorting And Searching
Which scenario will cause the longest execution time for a…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 708

Multiple choice Arrays
Consider the following code segment: public static void test(int[] a, int y) { if (a.length > 1) { a[1] = a[1] * 2; y…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 709

Multiple choice Sorting And Searching
Which of the following is (are) true? I. Insertion sort takes longer when the array is sorted in ascending order and you want it sorted in…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 710

Multiple choice Recursion
Consider the following code segment: private int[] arr; public int mystery(int low, int high, int num) { int mid = (low + high) / 2; if (low > high) { return…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 701 of 1,222
Page 71 of 123