Menu
Question Index
...

What will be the output of the following program?

public class FallThrough {
    public static void main(String[] args) {
        String str = "Hello";
        switch (str) {
            case "Hai" :
                System.out.print("Hai" + " ");
            case "Hello" :
                System.out.print("Hello," + " ");
            case "How" :
                System.out.print("how" + " ");
            case "Are" :
                System.out.print("are" + " ");
            case "You" :
                System.out.print("you");
            default :
                System.out.print("?");
        }
    }
}


Hello,
Hello, how are you
Hello, how are you?
Hai Hello, how are you?
Compilation Error or Runtime Error

Doubts

Problems

Topic: Fall Through Switch Case 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