Switch expressions with arrows
QuizMediumJava only
Which statements about this switch expression are true? Pick all that apply.
String type = switch (day) {
case 1, 7 -> "weekend";
case 2, 3, 4, 5, 6 -> {
String t = "week";
yield t + "day";
}
default -> "bad";
};- Arrow labels do not fall through to the next case
yieldreturns the value from a block inside a switch expression- The
defaultline can be removed because days are 1 to 7 - One case can list several values separated by commas
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.