What gets printed when the following expression is evaluated? Select the one correct answer. ${(1==2) ? 4 : 5}

  1. 1

  2. 2

  3. 4

  4. 5


Correct Option: D
Explanation:

To solve this question, the user needs to understand the concept of a ternary operator and the logical comparison operator.

The expression (1==2) will evaluate to false since 1 is not equal to 2.

The ternary operator ? : has the syntax condition ? value_if_true : value_if_false.

Therefore, the expression will evaluate to 5 since false is equivalent to 0, and the value if false is 5.

So, the answer is:

The Answer is: D. 5

Find more quizzes: