Menu
Question Index
...

What will be the output of the following program?

public class Prize {
    public static void main(String args[]) {
        int x = 111, y = 101;
        switch (x & y) {
            case 1 :
                System.out.println("-1-");
            case 101 :
                System.out.println("-101-");
            case 111 :
                System.out.println("-111-");
            case 010 :
                System.out.println("-010-");
            default :
                System.out.println("-" + x & y + "-");
        }
    }
}


-101-
-101-
-111-
-010-
-111-
-1-
-101-
-111-
-010-
-1-
-101-
-111-
-010-
-101-
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: switch Statement 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