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 451–460 of 1,222
  1. 451
  2. 452
  3. 453
  4. 454
  5. 455
  6. 456
  7. 457
  8. 458
  9. 459
  10. 460

Question 451

Multiple choice Arrays
Consider the following method. public int doStuff(int[] numberArray) { int index = 0; int maxCounter = 1; int counter = 1; for (int k = 1; k <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 452

Multiple choice Arrays
Consider the following method. public int changeEm(int num1, int num2, int[] values) { num1 = values[num2]; values[num1] = num2; num2++; return num2; } Consider…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 453

Multiple choice Arrays
The following code segment appears in the main method of another class. AnotherClass[] acArray = new AnotherClass[10]; acArray[2] = new AnotherClass("two");…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 454

Multiple choice Sorting And Searching
A programmer intends to apply the standard Binary Search algorithm on the following array of integers. The standard Binary Search algorithm returns the index of…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 455

Multiple choice 2D Arrays
Consider the following code segment. int[][] nums = { {0, 1, 2}, {3, 4, 5}, {6, 7, 8} }; for (int x = 0;x < nums.length;x++) { int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 456

Multiple choice Arraylists
Consider the following code segment. ArrayList<Integer> newList = new ArrayList<Integer>(); Integer[] list = {2, 4, 3, 3, 2, 5, 1}; newList.add(list[0]); for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 457

Multiple choice 2D Arrays
Consider the following code segment. int [] [] a = new int [5] [5]; for (int r = 0;r < a.length;r++) for (int c = r + 1;c < a[0].length;c++) a[r][c] = 9; for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 458

Multiple choice Sorting And Searching
Consider the following sorting method. public void mysterySort(int[] arr) { for (int j = 1; j < arr.length; j++) { int temp = arr[j]; int index = j; while…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 459

Multiple choice Recursion
Consider the following method. public int puzzle(int m, int n) { if (n == 1) return…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 460

Multiple choice 2D Arrays
Consider the following code segment. int [] [] table = new int [5] [6]; int val = 0; for (int k = 0;k < table[0].length;k++) { for (int j…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 451 of 1,222
Page 46 of 123