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 171–173 of 173
  1. 171
  2. 172
  3. 173

Question 171

Multiple choice Arraylists
Consider the following code segment.
ArrayList<Integer> values = new ArrayList<Integer>();
values.add(2);
values.add(5);
values.add(1);
values.add(5);

for (int i = values.size() - 1; i >= 0; i--)
{
    if (values.get(i) == 5)
        values.remove(i);
}

System.out.println(values);
What is printed?
Pick an answer, then check it. The solution opens in a window.

Question 172

Multiple choice Arraylists
Consider the following code segment. ArrayList<String> words = new ArrayList<String>(); words.add("ant");…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 173

Multiple choice Arraylists
Consider the following code segment. ArrayList<Integer> nums = new ArrayList<Integer>(); nums.add(2); nums.add(4); nums.add(3); nums.add(5);…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 171 of 173
Page 18 of 18