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 1,101–1,110 of 1,222
  1. 1101
  2. 1102
  3. 1103
  4. 1104
  5. 1105
  6. 1106
  7. 1107
  8. 1108
  9. 1109
  10. 1110

Question 1101

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 1102

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 1103

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 1104

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 1105

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 1106

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 1107

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 1108

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 1109

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 1110

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,101 of 1,222
Page 111 of 123