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.

Subtopic: Arraylists Clear filter

Questions 101–110 of 173
  1. 101
  2. 102
  3. 103
  4. 104
  5. 105
  6. 106
  7. 107
  8. 108
  9. 109
  10. 110

Question 101

Multiple choice Arraylists
ArrayList<String> xyz = new ArrayList<String>(); xyz.add("X"); xyz.add("Y"); xyz.add("Z"); int count = 0; for (String s1 : xyz) { for…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 102

Multiple choice Arraylists
Consider the following class. public class BankAccount { private int balance; public BankAccount() { balance = 0; } public BankAccount(int amt) { balance = amt;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 103

Multiple choice Arraylists
Consider the following code segment. ArrayList<Integer> numbers = new ArrayList<Integer>(); numbers.add(0); numbers.add(1); for (int k = 1; k <= 3; k++) { int n…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 104

Multiple choice Arraylists
Consider the following code segment: ArrayList<String> cities = new ArrayList<String>(); cities.add("Atlanta"); cities.add("Boston");…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 105

Multiple choice Arraylists
What happens when the size of an ArrayList<Integer>…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 106

Multiple choice Arraylists
Suppose ArrayList<Integer> numbers and ArrayList<String> names are created as follows: ArrayList<Integer> numbers = new ArrayList<Integer>(); Integer x = 1;…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 107

Multiple choice Arraylists
Consider the following method: /** * Rearranges the elements in words according to the values stored in an integer array indices, * so that the element of words…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 108

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 109

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 110

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 101 of 173
Page 11 of 18