AP CSA Unit 4 Day 13: Arraylist Remove Return Value

Unit 4, Data Collections • Cycle 2
Day 13 Advanced Practice • Harder Difficulty
Focus: ArrayList Remove Return Value Hard ArrayList Remove Return Value

Advanced Practice Question

Format: ArrayList Remove Return Value

What is the output?
ArrayList items = new ArrayList<>();
items.add("A");
items.add("B");
items.add("C");

String removed = items.remove(1);

System.out.println(removed);
System.out.println(items);
Difficulty: Hard  |  Topic: ArrayList Remove Return Value  |  Cycle: 2 (Advanced)
Why This Answer?

remove(1) removes and returns the element at index 1 ("B"). The list becomes [A, C]. Prints: B then [A, C].

Common Mistake
Watch Out!

Not knowing that remove() returns the removed element.

AP Exam Strategy

remove(index) removes the element AND returns it.

Master This Topic

This Cycle 2 HARD question tests arraylist remove return value. Review Unit 4 concepts to build mastery of data collections.

  • Understanding arraylist remove return value
  • Tracing code execution accurately
  • Avoiding common pitfalls
View Unit 4 Study Guide

Ready for More Challenges?

Cycle 2 questions prepare you for the hardest AP CSA exam questions.

Study Games Practice FRQs
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.