Question discussion

What will be the output of the following Java code?

359044Medium DSSSB TGT Computer Science 0 replies 0 views
0
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");
        }
    }
}
  • ANumber is less than 5
  • BCompilation error
  • CNumber is greater than 5
  • DNo output
Correct answer: C

Explanation

number = 10 > 5, so the condition is true and "Number is greater than 5" is printed.

Discussion 0

Nobody has replied yet. Start the discussion!