Menu
Question Index
...

What will be the output of the following program.

class Quarters
{
    public static void main(String s[])
    {
        int month = 5;

        switch(month)
        {
            case 1:
            case 2:
            case 3:
                System.out.println("First Quarter");
                break;
            case 4:
            case 5:
            case 6:
                System.out.println("Second Quarter");
                break;
            case 7:
            case 8:
            case 9:
                System.out.println("Third Quarter");
                break;
            case 10:
            case 11:
            case 12:
                System.out.println("Fourth Quarter");
                break;
        }
    }
}


No Output
Compilation Error - since some case statements does not have any code.
Compilation Error - since some case statements does not have break
Second Quarter
Second Quarter
Third Quarter
Fourth Quarter

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