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.

Subtopic: Arraylists Clear filter

Questions 121–130 of 225
  1. 121
  2. 122
  3. 123
  4. 124
  5. 125
  6. 126
  7. 127
  8. 128
  9. 129
  10. 130

Question 121

Multiple choice Arraylists
What is printed as a result of executing the following code segment? ArrayList<String> digits = new ArrayList<String>(); for (int k = 0; k <= 9; k++)…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 122

Multiple choice Arraylists
A class Turtle has a void method forward(int d) that moves the turtle forward by d units. A class TurtleRace has a list of Turtle objects: private…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 123

Multiple choice Arraylists
Consider the following method intended to remove all elements with a value less than zero from an ArrayList<Integer>: public void…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 124

Multiple choice Arraylists
Consider the following incomplete method, which shuffles a list of Card objects so that any card can end up at any index in the list deck, with equal…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 125

Multiple choice Arraylists
The method addStars is intended to append "*" at the end of each string in the ArrayList<String> words. Which of the following implementations of addStars will…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 126

Multiple choice Arraylists
public class APTestResult { private String subject; private int score; public int getScore() { return score; } // constructor and other methods not shown }…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 127

Multiple choice Arraylists
What is printed when the following code segment is executed? int[] factors = {2, 3, 5}; ArrayList<Integer> products = new ArrayList<Integer>(); products.add(1);…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 128

Multiple choice Arraylists
What is printed when the following code segment is executed? ArrayList<Integer> lst = new ArrayList<Integer>(); for (int k = 1; k <= 6;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 129

Multiple choice Arraylists
Consider the following code segment: List<String> list = new ArrayList<String>(); list.add("a"); list.add("b"); list.set(1, "c");…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 130

Free response Arraylists
This question involves the process of taking a list of words, called wordList, and producing a formatted string of a specified length. The list wordList…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 121 of 225
Page 13 of 23