A

Admin • 830.13K Points
Coach

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

Code:
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentSkipListMap;

public class ConcurrentSkipMapTest {

public static void main (String args[])
{
Map<Integer,String>concurrentSkipListMap= new ConcurrentSkipListMap<Integer,String>();
concurrentSkipListMap.put(11,”audi”);

Iterator<Integer> keyIterator = concurrentSkipListMap.keySet().iterator();
while (keyIterator.hasNext())
{
System.out.print(keyIterator.next());
concurrentSkipListMap.put(13,”bmw”);
}
}

}
  • (A) 11 followed by ConcurrentModificationException
  • (B) 11
  • (C) ConcurrentModificationException
  • (D) Compile time exception
  • Correct Answer - Option(B)
  • Views: 17
  • 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.