Given:

What is the result?
Given:
What is the result?
The code will throw a ConcurrentModificationException at runtime. The reason is that the modification of the ArrayList (using al.remove(2)) occurs while it's being iterated. The Iterator's contract specifies that modifying the collection while iterating through it, using methods other than those provided by the iterator itself, results in a ConcurrentModificationException.
C is correct java.util.ConcurrentModificationException
Answer: C
Tested: C.
C is ok java.util.ConcurrentModificationException
answer: C should be it.remove(); interesting that it wil be ok : if (it.next() == 2) { al.remove(2; break;