Menu
Question Index
...

What will be the output of the following program?

public class SwitchInSwitch {
    public static void main(String[] args) {
        int x = 3, y = 4, z = 5;
        switch (x) {
            case 3 :
                System.out.print(x + "~");
                switch (y) {
                    case 4 :
                        System.out.print(y + "~");
                        switch (z) {
                            case 5 :
                                System.out.print(z + "~");
                        }
                }
            default :
                System.out.print("Switch in Switch");
        }
    }
}


3~4~5~
3~Switch in Switch4~5~
3~4~5~Switch in Switch
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