Skip to main content

Practice · 1 of 8

MCQ: While iterating, which list survives? Code:

CHALLENGE
Difficulty: advanced+25 XP

While iterating, which list survives? Code: ``java ArrayList<String> list = new ArrayList<String>(); list.add("x"); list.add("x"); list.add("b"); list.add("x"); for (int i = 0; i < list.size(); i++) { if (list.get(i).equals("x")) { list.remove(i); } } System.out.print(list); ` A. [b] B. [x, b] C. [b, x] D. [x, x, b]` Print your answer as: the option letter, then your explanation of why it is correct and why each other option is wrong. First line must start with the letter.

Back to lesson: Practice: MCQ set 1: read the misconception