Practice · 3 of 4
Exam MCQ
CHALLENGE
Difficulty: advanced+25 XP
Which statement about this code is TRUE?
``java
ArrayList<String> list = new ArrayList<String>();
list.add("a");
list.add("b");
for (String item : list) {
if (item.equals("a")) { list.remove(item); }
}
``
A. It removes "a" safely
B. It throws ConcurrentModificationException
C. It removes nothing
D. It removes both elements
Print the letter, then your one-sentence justification.
Press Submit to check your solution.
Back to lesson: Practice: Exam #3: MCQ section