Menu
Question Index
...

What will be the output of the following program?

public class Mock {
    public static void main(String args[]) {
        int z = 3;
        for (int i = 0; i < 2; i++) {
            switch (z) {
                case 3 :
                    System.out.print((z = z + 1) + " ");
                case 5 :
                    System.out.print((z = z + 2) + " ");
                    break;
                default :
                    System.out.print((z = z + 8) + " ");
                case 6 :
                    System.out.print((z = z + 4) + " ");
            }
        }
    }
}


12 16
4 6 7
4 6 10
4 7 15 19
Compilation Error or Runtime Error

Doubts

Problems

Topic: for Loop 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