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 821–830 of 1,079
  1. 821
  2. 822
  3. 823
  4. 824
  5. 825
  6. 826
  7. 827
  8. 828
  9. 829
  10. 830

Question 821

Multiple choice 2D Arrays
What is the value of sum after the following executes? int[][] grid = { {1, 2, 3}, {4, 5,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 822

Multiple choice Arraylists
Consider traversing an ArrayList while removing elements. Which approach avoids skipping elements? // Approach I – forward traversal for (int i = 0; i <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 823

Multiple choice Arrays
Consider the following method: public static int[] doubleArray(int[] arr) { int[] result = new int[arr.length]; for (int i = 0; i <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 824

Multiple choice Arrays
What is the output of the following code? int[] arr = {5, 3, 8, 1, 9}; int result = arr[0]; for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 825

Multiple choice Arraylists
Consider the following: ArrayList<Integer> list = new…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 826

Multiple choice 2D Arrays
What does the following method return for input [[1,2],[3,4],[5,6]]? public static int colSum(int[][] m, int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 827

Multiple choice Using Text Files
// Assume: File f = new File("data.txt"); // File contains space-separated integers…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 828

Multiple choice Arraylists
An ArrayList<Integer> named scores contains [85, 92, 78, 96,…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 829

Multiple choice Arraylists
An ArrayList<Integer> named list contains [2, 4, 6, 8, 10]. The following loop runs: for (int i = 0; i…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 830

Multiple choice 2D Arrays
Consider the following code that processes a 2D array: int[][] g = {{1,2,3},{4,5,6},{7,8,9}}; int total = 0; for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 821 of 1,079
Page 83 of 108