Computer Applications
Predict the output of the below Java program snippet:
int a = 14, b = 4;
boolean x = (a > b) ? true : false;
Java
Java Operators
42 Likes
Answer
true
Working
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.
Answered By
22 Likes
Related Questions
Write the Java expression for the following:
Predict the output of the below Java program snippet:
int c = (3<4)? 3*4:3+4;Predict the output of the below Java program snippet:
int x = 90; char c = (x<=90)?'Z':'I';Predict the output of the below Java program snippet:
int a = 18; int b = 12; boolean t = (a > 20 && b < 15)? true : false;