Programs get smart when they choose. if/else tests conditions; switch matches one value against fixed cases.
1 if / else if / else
Conditions are tested top to bottom — the first true branch runs and the rest are skipped.
2 switch
One value, many cases: a cleaner ladder when you are matching fixed options like menu choices.
3 break stops it
Without break, a matching case falls through into the next one — usually a bug.
4 default catches all
The case that runs when nothing else matched — a safety net for surprise values.
Choices, choices
if / else if / else1Conditions are tested top to bottom — the first true branch runs and the rest are skipped.
switch2One value, many cases: a cleaner ladder when you are matching fixed options like menu choices. break stops it3Without break, a matching case falls through into the next one — usually a bug. default catches all4The case that runs when nothing else matched — a safety net for surprise values. 4 building blocks make up Choices, choices
Press play and follow score 78 as each condition is tested top to bottom until one says true.
JVMThe JVM loads the Grader class into memory.
Memory
no variables yet — press play
Console
output appears as the program runs…
A switch jumps straight to the matching case — and every break stops the fall-through before the next case.
process decision input / output start / end Click a keyword, then click its job to lock the pair.
5 conceptsTap a card to expand ?ifdrops into place
?else ifdrops into place
?switchdrops into place
?breakdrops into place
?defaultdrops into place
A switch with a missing break — trace where execution falls before you guess.
Your predicted output — one line per console line
Hint: case 1 has no break — execution falls through into the next case until a break stops it.
01if/else if/else tests conditions top to bottom — the first true branch wins.
02switch matches one value against fixed cases — cleaner than long ladders.
03Every case needs a break, or execution falls into the next case.
04default catches every value that no case handled.