Menu
Question Index
...

What will be the output of the following program?

public class WhatHeDoing {
    public static void main(String[] args) {
        for (NAMES type : NAMES.values()) {
            switch (type.str) {
                case "Kiran" :
                    System.out.print(type + " ");
                    break;
                case "Ashok" :
                    System.out.print(type + " ");
                    break;
                case "Oleti" :
                    System.out.print(type + " ");
                    break;
                default :
                    System.out.print(type + " ");
                    break;
            }
        }
    }
}
enum NAMES {
    STUDENT("Kiran"), EMPLOYEE("Ashok"), BUSINESS("Dharma"), ENTREPRENEUR("Oleti");
    String str;
    NAMES(String str) {
        this.str = str;
    }
}


STUDENT EMPLOYEE BUSINESS ENTREPRENEUR
BUSINESS BUSINESS BUSINESS BUSINESS
Some other output
Output can not be determined
Compilation Error or Runtime Erro

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