1
visibility

Predict the output ?
int a = 14, b = 4;
boolean x = (a > b) ? true : false;

  • 14

  • true

  • false

  • 4

As 14 is greater than 4 so condition of ternary operator is true. Variable x is assigned the value of expression 1 which is true.