Question 21Asked in DSSSB TGT Computer Science (Technical), 12 Sep 2025, Shift 3 (5:00 PM)

int a = 4, b = 8, c = 6; if (a > b) {

int a = 4, b = 8, c = 6; if (a > b) { if (a > c) { System.out.println("a is the largest"); } else if (b > c) { System.out.println("b is the largest"); } else { System.out.println("c is the largest"); } } else { if (b > c) { System.out.println("b is the largest"); } else { System.out.println("c is the largest"); } } What is the output of the above code snippet( Assume that it is written inside main() function )?
  1. Ac is the largest
  2. Bb is the largest
  3. Ca is the largest
  4. DCompilation error
Show answerHide answer

Correct answer: (B) b is the largest

Explanation

a > b (4 > 8) is false, so the outer else block runs. There b > c (8 > 6) is true, so "b is the largest" is printed.

From DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 3 (5:00 PM)

This is question 21 of DSSSB TGT Computer Science PYQ (Technical), 12 Sep 2025, Shift 3 (5:00 PM). 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.