Menu
Question Index
...

What will be the output of the following program? Assume that we are using JDK1.7?

public class Select {
    public static void choose(String str) {
        switch (str) {
            case "M" :
                System.out.print("Merit ");
            case "C" :
                System.out.print("Campus");
                break;
            case "W" :
                System.out.print("Welcome ");
                break;
            case "T" :
                System.out.print("To ");
                break;
            case "H" :
                System.out.println();
            default :
                System.out.println("Default");
                break;
        }
    }
    public static void main(String arg[]) {
        Select.choose("W");
        Select.choose("M");
        Select.choose("w");
    }
}


Merit Campus
Welcome Merit CampusDefault
Welcome Merit Campus
Default
Welcome Merit Campus Default
Compilation Error or Runtime Error

Doubts

Problems

Topic: Static and Non Static Variables - Static and Non Static Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App