Home Tutorial Java Scjp Part1 SCJP Module-1 Question-25

 
 

Share on Google+Share on Google+
SCJP Module-1 Question-25
Posted on: July 21, 2010 at 12:00 AM
Advertisement
The Sample program given below will test your understanding about the switch case and enum data type in Java.

Given a sample code:

1    class Test {
2    public enum Man {
3    RAJ, SURAJ, DINESH, GUYS
    };

4    public static void main(String[] args) {
5    Man me = Man.GUYS;
6    switch (me) {
7    case RAJ:
8    System.out.print("Raj ");
9    case SURAJ:
10  System.out.print("Suraj ");
11  default:
12  System.out.print("Anyone ");
}}}

What will be the result? Choose the correct option?

(A) Raj Suraj Anyone
(B) Runtime error.
(C) Compilation error at line no 5.
(D) Anyone

Answer:

(D)

Advertisement

Related Tags for SCJP Module-1 Question-25:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 21, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com