SCJP Module-9 Question-12


 

SCJP Module-9 Question-12

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

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".

Ads