Verityprep
Question Bank · Unit 4

AP® Computer Science A Data Collections Multiple Choice Questions

Work through AP Computer Science A multiple-choice 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 801–810 of 1,079
  1. 801
  2. 802
  3. 803
  4. 804
  5. 805
  6. 806
  7. 807
  8. 808
  9. 809
  10. 810

Question 801

Multiple choice Arraylists
Consider the following method. public void reviseList(ArrayList<Integer> list) { for (int i = 0; i < list.size(); i++) { int temp = list.get(i); if (temp % 2 ==…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 802

Multiple choice 2D Arrays
Consider the following code segment. int[][] arr2D = /* missing initialization */; int sum = 0; for (int j = 0; j < arr2D.length; j++) { sum +=…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 803

Multiple choice 2D Arrays
Consider the following code segment. int[][] arr = {{10, -7, 19, 14}, {-3, -2, -6, 11}, {-9, 12, 10, -1}}; int ans = 1; for (int[] row : arr) { for (int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 804

Multiple choice Sorting And Searching
The following method is a correct implementation of the selection sort algorithm. The method sorts the elements of arr so that they are in order from least to…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 805

Multiple choice Recursion
Consider the following method. public static void mystery(int j, int k) { if (j > k) { mystery(j -…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 806

Multiple choice Arraylists
Consider the following code segment. What is printed when this code is executed? ArrayList<String> list = new ArrayList<>(); list.add("apple");…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 807

Multiple choice Using Text Files
info.txt contains exactly 2.5 Hello World. The file exists, opens successfully, and the enclosing method handles checked file-opening exceptions. What happens?…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 808

Multiple choice Using Text Files
Does this method compile? Assume the imports are present. public void readFile(String filename){ java.util.Scanner scan=new…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 809

Multiple choice Using Text Files
data.txt contains one line: Hello-World-AP-CSA. The file opens successfully and checked exceptions are handled by the enclosing method. What is printed?…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 810

Multiple choice Using Text Files
Consider the following method. public static void readFile(String filename) { File file = new File(filename); Scanner sc = new…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 801 of 1,079
Page 81 of 108