Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class DayOfWeek {
    public static void main(String[] a) {
        int day = 1;
        switch (day) {
            case Calendar.MONDAY :
                System.out.print("Mon" + getDay());
            case Calendar.TUESDAY :
                System.out.print("Tues" + getDay());
            case Calendar.WEDNESDAY :
                System.out.println("Wednes" + getDay());
            case Calendar.THURSDAY :
                System.out.print("Thurs" + getDay());
            case Calendar.FRIDAY :
                System.out.print("Fri" + getDay());
            case Calendar.SATURDAY :
                System.out.print("Satur" + getDay());
            case Calendar.SUNDAY :
                System.out.print("Sun" + getDay());
        }
    }
    private static String getDay() {
        return "day~";
    }
}


Sunday~
Monday~Tuesday~Wednesday~
Thursday~Friday~Saturday~Sunday~
Tuesday~Wednesday~
Thursday~Friday~Saturday~Sunday~
Compilation Error or Runtime Error

Doubts

Problems

Topic: Calendar In Java - java.util.Calendar Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App