InterviewSolution
Saved Bookmarks
| 1. |
System.out.println(25> 15 ? 100 200). |
|
Answer» nippet System.out.println(25 > 15 ? 100 : 200);Output 100Explaination As, 25 is more than 15, 100 is printed.Ternary (or CONDITIONAL) OperatorIt is a cut short notation of SIMPLE conditional statements.When a CONDITION is evaluated to true the statement after the ? is executed otherwise the statement after the : gets executed. Syntax - test-condition ? statement1 : statement2; So, if the test-condition is evaluated to true, statement1 gets executed otherwise statement2 gets excecuted. |
|