Menu
Question Index
...

What will be the output of the following program?

public class MoreSwitches {
    public static void main(String args[]) {
        char status = 'P';
        int year = 3;
        switch (status) {
            case 'F' :
                System.out.print("Student Failed ");
            case 'P' :
                System.out.print("Student Passed ");
                switch (year) {
                    case 1 :
                        System.out.print(year + " Year");
                    case 2 :
                        System.out.print(year + " Year");
                    case 3 :
                        System.out.print(year + " Year");
                }
        }
    }
}


Student Passed 3 Year
Student FailedStudent Passed 3 Year3 Year3 Year
Some other output
Compilation Error
Runtime Error

Doubts

Problems

Topic: Nested switch Statements In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App