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 1,001–1,010 of 1,079
  1. 1001
  2. 1002
  3. 1003
  4. 1004
  5. 1005
  6. 1006
  7. 1007
  8. 1008
  9. 1009
  10. 1010

Question 1001

Multiple choice Arraylists
public static void removeNegatives(ArrayList<Integer> list) { for (int i = 0;i < list.size();i++) { if (list.get(i) < 0)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1002

Multiple choice Arraylists
The Player class is defined as follows: public class Player { private String name; private int score; public Player(String name, int score) { this.name = name;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1003

Multiple choice Arraylists
public static void insertBeforeOld(ArrayList<String> words) { for (int i = 0;i < words.size();i++) { if…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1004

Multiple choice 2D Arrays
Consider the following code: public static int findMaxRowSum(int[][] grid) { int maxSum = 0; for (int row = 0; row < grid.length; row++) { int rowSum = 0; for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1005

Multiple choice 2D Arrays
Consider the following code: public static String buildOrder(int[][] grid) { String result = ""; for (int col = 0;col < grid[0].length;col++) { for (int row =…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1006

Multiple choice 2D Arrays
Consider the following code: public static void flipHorizontal(int[][] grid) { for (int row = 0;row < grid.length;row++) { for (int col = 0;col <…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1007

Multiple choice 2D Arrays
Consider the following code: public static int countNeighbors(int[][] grid, int row, int col) { int count = 0; for (int r = row - 1; r <= row + 1; r++) { for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1008

Multiple choice Using Text Files
Suppose the file "numbers.txt" contains: 8 -3 12 -1 4 public static int averagePositive(String filename) { Scanner scan = new Scanner(new File(filename)); int…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1009

Multiple choice Using Text Files
Suppose the file 'words.txt' contains: hello world java code public static String readOddLines(String filename) { Scanner scan = new Scanner(new…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1010

Multiple choice Arraylists
public static int processAndReturn(ArrayList<Integer> nums) { int total = 0; for (int i = 0;i < nums.size();i++) { int val = nums.get(i);…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 1,001 of 1,079
Page 101 of 108