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:

Motivations on Perception

Refers to how internal drives and desires influence one's interpretation of sensory information.

Impact of Emotion

The effect that emotions have on human processes and behaviors, including decision making, creativity, relationships, and physical health.

Synesthesia

A neurological condition where stimulation of one sensory or cognitive pathway leads to automatic, involuntary experiences in a second sensory or cognitive pathway.

Tinnitus

A condition characterized by hearing noises that are not caused by an external source, often described as ringing in the ears.

Related Questions