Menu
Topics Index
...
`

Fall Through


If you need explanation Read this topic

If you need Answer Take test on this topic

Fall Through
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("?");
        }
    }
}

A. Hello,
B. Hello, how are you
C. Hello, how are you?
D. Hai Hello, how are you?
E. Compilation Error or Runtime Error
Topic: Fall Through Switch Case Statements In Java

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.

Ans c..thr is no break so all case wil print

Posted by Uday Kumar    2014-08-01 03:42:33


Ans c, y bcoz case haven't break;

Posted by Govindarao Parella    2014-08-01 05:23:35


c

Posted by Manojkumar Kothagulla    2014-08-01 13:24:37


c.........'coz there is no available of break stmt......

Posted by Arul Palanisamy    2014-08-02 04:19:00


C no break statement

Posted by Datta Sai Krishna    2014-08-02 10:29:30


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

Posted by Merit Campus    2014-08-04 06:03:36


© meritcampus 2019

All Rights Reserved.

Open In App