Difficulty: Easy
Correct Answer: -65321
Explanation:
Introduction / Context:This tests knowledge of integer literal ranges for a 16-bit int. While modern systems typically use 32-bit int, many exam questions still assume a 16-bit range for portability and historical reasons.
Given Data / Assumptions:
int range: −32768 to +32767.Concept / Approach:Any literal outside the stated range is invalid for assignment to a 16-bit int without causing overflow or requiring a larger integer type. The syntax of the constants is otherwise standard (leading + or − sign allowed).
Step-by-Step Solution:
321, −162, +1, and 0 are clearly within −32768…+32767.−65321 is much less than −32768; it is out of range for a 16-bitint.Hence, −65321 is not a valid 16-bit integer constant under the assumption.Verification / Alternative check:Consider storage width: 16-bit two’s complement cannot encode magnitude 65321; wrap-around would occur if forced, which is undefined/implementation-specific in literal typing context.
Why Other Options Are Wrong:
All other values fall within the representable range and thus are valid.Common Pitfalls:
Forgetting that the negative bound (−32768) has magnitude one larger than the positive bound (+32767) in two’s complement.Final Answer:
-65321
Discussion & Comments