Computer Applications

Consider the following code snippet:


if ( c > d)
x = c;
else
x = d;

Choose the correct option if the code mentioned above is rewritten using the ternary operator:

  1. x = (c >d) ? c : d;
  2. x = (c >d) ? d : c;
  3. x = (c >d) ? c : c;
  4. x = (c >d) ? d : d;

Java Conditional Stmts

12 Likes

Answer

x = (c >d) ? c : d;

Answered By

1 Like


Related Questions