Menu
Question Index
...

What will be the output of the following program.

class Directions
{
    public static void main(String s[])
    {
        char direction = 'E';

        switch(direction)
        {
            case 'N':
                System.out.println("North");
                break;
            case 'E':
                System.out.println("East");
            case 'W':
                System.out.println("West");
                break;
            case 'S':
                System.out.println("South");
        }
    }
}


East
West
Compilation Error - since char datatype can not be used in switch statement.
East
East
South

Doubts

Problems

Topic: Using break in switch case Statement

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App