SCJP Module-9 Question-12

The sample example given below will test your understanding of EnumMap in Java.

 
 

Share on Google+Share on Google+

SCJP Module-9 Question-12

Ads

The sample example given below will test your understanding of EnumMap in Java.

Given below the sample code :

11 EnumMap< Integer> frequencyEnumMap = new EnumMap< Integer>(ordinaryMap);
12 frequencyEnumMap.put(null, 100);
13 System.out.println("Frequency EnumMap: " + frequencyEnumMap);

What will be the output of the above code ?

1. compile error

2. 100

3. null

4. NullPointerException

Answer

(1)

Explanation

The 'null' reference key is NOT permitted in "Map".

Advertisements

Posted on: July 17, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles