Menu
Question Index
...

What will be the output of the following program?

public class People {
    public static void main(String[] args) {
        for (NAMES type : NAMES.values()) {
            switch (type) {
                default :
                    System.out.print(type + " ");
            }
        }
    }
}
enum NAMES {
    KIRAN("Kiran"), ASHOK("Ashok"), DHARMA("Dharma"), OLETI("Oleti");
    String str;
    NAMES(String str) {
        this.str = str;
    }
}


KIRAN ASHOK DHARMA OLETI
Kiran Ashok Dharma Oleti
Some other output
Output can not be determined
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Enumeration

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App