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

What will be the output of the following Java code? public class IfExample {

What will be the output of the following Java code? public class IfExample { public static void main(String[] args) { int number = 10; if (number > 5) { System.out.println("Number is greater than 5"); } } }
  1. ANumber is less than 5
  2. BCompilation error
  3. CNumber is greater than 5
  4. DNo output
Show answerHide answer

Correct answer: (C) Number is greater than 5

Explanation

number = 10, so number > 5 is true and the if block prints "Number is greater than 5".

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

This is question 40 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.