Difficulty: Easy
Correct Answer: tiny
Explanation:
Introduction / Context:
This checks understanding of nested ternary operators and left-to-right evaluation of conditions.
Given Data / Assumptions:
Concept / Approach:
Evaluate the first condition. If false, evaluate the second condition in the nested ternary. The chosen string is then printed.
Step-by-Step Solution:
Verification / Alternative check:
Rewrite using if/else to confirm: if (x < 15) "small"; else if (x < 22) "tiny"; else "huge".
Why Other Options Are Wrong:
"small" would require x < 15; "huge" would require x >= 22; no compilation issues here.
Common Pitfalls:
Misgrouping nested ternary operators or forgetting that they are right-associative.
Final Answer:
tiny
Discussion & Comments