Computer Science, asked by perween283, 3 months ago

System.out.println(25> 15 ? 100 200).​

Answers

Answered by Oreki
1

Given Snippet

   System.out.println(25 > 15 ? 100 : 200);

Output

   100

Explaination

    As, 25 is more than 15, 100 is printed.

Ternary (or Conditional) Operator

It 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.

Similar questions