Multiple choice

What will be the output of the program? class Test { public static void main(String [] args) { int x=20; String sup = (x < 15) ? "small" : (x < 22)? "tiny" : "huge"; System.out.println(sup); } }

  1. small

  2. tiny

  3. huge

  4. Compilation fails

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

This is an example of a nested ternary operator. The second evaluation (x < 22) istrue, so the "tiny" value is assigned to sup.