A

Admin • 830.13K Points
Coach

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
  • Correct Answer - Option(A)
  • Views: 16
  • Filed under category Java
  • Hashtags:

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.

Be the first to start discuss.