Examlex

Solved

Public Class EnumExample

question 54

Essay

public class EnumExample
{
    enum Day {SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
              THURSDAY, FRIDAY, SATURDAY };

    Day day;

    public EnumExample(Day day)
    {
        this.day = day;
    }

    public void giveFeedback()
    {
        switch (day)
        {
            case MONDAY:
                System.out.println("Mondays are bad.");
                break;

            case FRIDAY:
                System.out.println("Fridays are better.");
                break;

            case SATURDAY: case SUNDAY:
                System.out.println("Weekends are best.");
                break;

            default:
                System.out.println("Midweek days are so-so.");
                break;
        }
     }

    public static void main(String[] args)
    {
        EnumExample firstDay = new EnumExample(Day.MONDAY);
        firstDay.giveFeedback();
        EnumExample thirdDay = new EnumExample(Day.WEDNESDAY);
        thirdDay.giveFeedback();
        EnumExample fifthDay = new EnumExample(Day.FRIDAY);
        fifthDay.giveFeedback();
        EnumExample sixthDay = new EnumExample(Day.SATURDAY);
        sixthDay.giveFeedback();
        EnumExample seventhDay = new EnumExample(Day.SUNDAY);
        seventhDay.giveFeedback();
    }
}
Using the above enumeration and code, what will be the output when the program is executed?


Definitions:

Wolves

Large carnivores belonging to the canine family, known for their social structure and roles in ecosystems as apex predators.

Psychopathology

The study of mental disorders, including their symptoms, etiology (causes), and treatment.

Mental Illness

An expansive range of conditions related to mental health, influencing emotional well-being, cognitive function, and conduct.

Parity Laws

Laws that direct insurance companies to provide equal coverage for mental and physical problems.

Related Questions