Practice · 3 of 4
Exam MCQ
CHALLENGE
Difficulty: advanced+25 XP
Which completes the removal correctly (remove all "x")?
``java
ArrayList<String> list = ...; // [x, b, x, x]
for (int i = list.size() - 1; i >= 0; i--) {
if (list.get(i).equals("x")) { list.remove(i); }
}
``
A. Correct as written
B. Fails: needs i++ inside
C. Fails: forward loop required
D. Fails: remove(i--) required
Print the letter, then your one-sentence justification.
Press Submit to check your solution.
Back to lesson: Practice: Exam #1: MCQ section