Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class AddNumbers {
    enum NUMBERS {
        One, Two, Three, Four;
    }
    public static void main(String[] args) {
        EnumMap<NUMBERS, Integer> em = new EnumMap<>(NUMBERS.class);
        em.put(NUMBERS.Two, 2);
        em.put(NUMBERS.One, 1);
        em.put(NUMBERS.Three, 3);
        em.put(NUMBERS.Four, 4);
        em.put(NUMBERS.Three, 5);
        System.out.println(em);
    }
}


{One=1, Two=2, Three=3, Four=4, Three=5}
{One=1, Two=2, Four=4, Three=5}
{One=1, Two=2, Three=3, Four=4}
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java EnumMap

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App