Multiple choice technology programming languages

What results from attempting to compile and run the following code? public class Ternary { public static void main(String args[]) { int a = 5; System.out.println("Value is - " + ((a < 5) ? 9.9 : 9)); } }

  1. prints: Value is - 9

  2. prints: Value is - 5

  3. Compilation error

  4. None of these

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

In the ternary expression, since one operand is double (9.9) and the other is int (9), the int is promoted to double, evaluating the expression to 9.0. Since Value is - 9.0 is not listed, 'None of these' is correct.