Skip to main content
Java Output Prediction Easy +10 XP

Ternary Operator

What does this print?

JavaRead-only
int x = 7;
String result = (x > 5) ? "big" : "small";
System.out.println(result);

What is the output?

Show answer and explanation

Answer: big

7 > 5 is true, so the ternary operator returns 'big'.

Hint: Is 7 greater than 5?

What this challenge tests

Output Prediction in Java: ternary, operators.

Related challenges