Which statement in this code is unreachable? switch (x)
Which statement in this code is unreachable?
switch (x)
{
Case 1:
a1 = 100;
Case 2:
a2 = 1000;
a3 = 10;
break;
a4 = 10000;
}
Show answerHide answer
Correct answer: (D) a4 = 10000;
Explanation
After break the control leaves the switch, and no case label precedes a4 = 10000;, so that statement can never be reached. a1, a2 and a3 run for cases 1 and 2 (case 1 falls through).