Question 51Asked in DSSSB TGT Computer Science (Technical), 1 Aug 2021, Shift 1

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; }
  1. Aa1 = 100;
  2. Ba2 = 1000;
  3. Ca3 = 10;
  4. Da4 = 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).

From DSSSB TGT Computer Science PYQ (Technical), 1 Aug 2021, Shift 1

This is question 51 of DSSSB TGT Computer Science PYQ (Technical), 1 Aug 2021, Shift 1. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.