Multiple choice technology programming languages

What's wrong? (x = 4 && y = 5) ? (a = 5) ; (b = 6);

  1. the question mark should be an equal sign

  2. the first semicolon should be a colon

  3. there are too many variables in the statement

  4. the conditional operator is only used with apstrings

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In the ternary operator syntax, the true and false branches must be separated by a colon (:), not a semicolon (;). The correct format is condition ? true_expression : false_expression; - the semicolon terminates the entire statement, not the branches.