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
πŸ’¬ Discuss
βœ… Correct Answer: (B) 11

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
286
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Uday Singh
Publisher
πŸ“ˆ
89%
Success Rate