Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 74

Given:

What is the result?

    Correct Answer: C

    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.

Discussion
ASPushkinOption: C

answer: C should be it.remove(); interesting that it wil be ok : if (it.next() == 2) { al.remove(2; break;

mendjijetOption: C

C is ok java.util.ConcurrentModificationException

OmnisumemOption: C

Tested: C.

tmuralimanoharOption: C

Answer: C

StavokOption: C

C is correct java.util.ConcurrentModificationException