ICSE Class 9 Computer Applications
Question 4 of 21
Operators in Java — Question 4
Back to all questions 4
Question Question 4
What is the use and syntax of a ternary operator?
Ternary operator is used to check if a condition is true and false. Depending on whether the condition tests true or false, expression 1 or expression 2 is evaluated. Its syntax is:
boolean-expression ? expression1 : expression2;