Predict the output of the below code ?

package com.infy;
public class Demo{
public static void main(String[] args) {
Day day=Day.TUESDAY;

switch (day) {
case Day.MONDAY -> System.out.println("Start of the week");
case Day.TUESDAY, Day.WEDNESDAY, Day.THURSDAY -> System.out.println("Weekday");
default -> System.out.println("Weekend");
}
}
}
enum Day {
MONDAY,TUESDAY,WEDNESDAY,THURSDAY
}

Weekday

Compilation Error: Enum type cannot be used with switch statement

Weekday 

Weekend

The code cannot be compiled as the qualified case label must be replaced with the unqualified enum constant

Verified Answer
Correct Option - d

To get all Infosys Certified Java SE 17 Developer Exam questions Join Group https://bit.ly/infy_premium_group

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in