Menu
Question Index
...

What will be the output of the following program?

public class Jerusalem {
    public static void main(String args[]) {
        int i = 1, j = 0;
        switch (i) {
            case 2 :
                j += 6;
            case 4 :
                j += 1;
            default :
                j += 2;
            case 0 :
                j += 4;
        }
        System.out.println("j = " + j);
    }
}


j = 0
j = 2
j = 4
j = 6
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