Question discussion

Which statement in this code is unreachable?

359853Medium DSSSB TGT Computer Science 0 replies 0 views
0

Which statement in this code is unreachable?

switch(x)
{
    case 1:
        a1 = 100;
    case 2:
        a2 = 1000;
        a3 = 10;
        break;
        a4 = 10000;
}
  • Aa1 = 100;
  • Ba3 = 10;
  • Ca2 = 1000;
  • Da4 = 10000;
Correct answer: D

Explanation

After "break;" in the same case block, control leaves the switch, so the statement "a4 = 10000;" can never be executed.

Discussion 0

Nobody has replied yet. Start the discussion!