Predict the output of the below Java program snippet:
int c = (3<4)? 3*4:3+4;
81 Likes
12
As 3 is less than 4 so condition of ternary operator is true. Variable c is assigned the value of expression 1 which is 3 * 4 = 12.
Answered By
41 Likes
int a = 14, b = 4; boolean x = (a > b) ? true : false;
int x = 90; char c = (x<=90)?'Z':'I';