Menu
Topics Index
...
`

What he is doning2325


If you need explanation Read this topic

If you need Answer Take test on this topic

What he is doning2325
What will be the output oft he following program?
public class WhatHeDoing {
    public static void main(String[] args) {
        for (NAMES type : NAMES.values()) {
            switch (type) {
                case "STUDENT" :
                    System.out.print(type.str + " ");
                    break;
                case "EMPLOYEE" :
                    System.out.print(type.str + " ");
                    break;
                case "ENTREPRENEUR" :
                    System.out.print(type.str + " ");
                    break;
                default :
                    System.out.print(type.str + " ");
                    break;
            }
        }
    }
}
enum NAMES {
    STUDENT("Kiran"), EMPLOYEE("Ashok"), BUSINESS("Dharma"), ENTREPRENEUR("Oleti");
    String str;
    NAMES(String str) {
        this.str = str;
    }
}

A. Kiran Ashok Dharma Oleti
B. STUDENT EMPLOYEE BUSINESS ENTREPRENEUR
C. Some other output
D. Output can not be determined
E. Compilation Error or Runtime Error
Topic: Java Enumeration

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

E : Coz of type mismatch,  cannot convert String to enum type.

Posted by Shaik Nyamath    2014-04-01 08:53:24


Ans is E.. Object type cant be compared with string type here we comparing STUDENT OBJECT with "STUDENT" string so it leads to compilation error..

Posted by Om Prakash Om    2014-04-01 08:55:06


Congratulations Shaik Nyamath. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-04-02 04:43:45


© meritcampus 2019

All Rights Reserved.

Open In App