A

Admin • 828.43K Points
Coach

Q. What will be the output of the following code –

Code:
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class CopyOnWriteArrayListTest
{
public static void main (String args[])
{
List<String> copyOnWriteArrayList = new CopyOnWriteArrayList<String>();
copyOnWriteArrayList.add(” Ind “);
copyOnWriteArrayList.add(” usa “);
copyOnWriteArrayList.add(null);
for(String string : copyOnWriteArrayList)
{
System.out.print(string+””);
copyOnWriteArrayList.add(“newEle3”) ;
}
}
}
  • (A) ind followed by NullPointerException
  • (B) ind followed by ConcurrentModificationException
  • (C) ind usa null
  • (D) Compile time exception
  • Correct Answer - Option(C)
  • Views: 15
  • 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.