Home / Programming MCQs / JAVA MCQs / Question

T

Tina Singh • 10.59K Points
Tutor II

Q. What will be the output of given code

Code:
import java.util.ArrayList;
import java.util. Iterator;
import java.util. List;

public class ArrayListTest {
public static void main (String args[])
{
List<String> arrayList = new ArrayList<String>();

arrayList.add(“a”);
arrayList.add(“b”);

Iterator<String> iterator = arrayList.iterator();

while (iterator.hasNext())
{
System.out.println(iterator.next());
arrayList.add(“c”);
}
}
}
(A) a followed by ConcurrentModificationException
(B) a b c
(C) a b
(D) a c

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.