Difficulty: Easy
Correct Answer: 0 to 65535
Explanation:
Introduction / Context:
Unlike C/C++, Java's char is a 16-bit unsigned integer type designed to hold UTF-16 code units. Knowing its range is useful when performing conversions and arithmetic involving characters.
Given Data / Assumptions:
Concept / Approach:
char uses 16 bits and is unsigned, so it ranges from 0 to 2^16 - 1 = 65535. This is independent of platform or CPU architecture (Java's types are platform-independent).
Step-by-Step Solution:
Verification / Alternative check:
Review the Java Language Specification: char is an unsigned 16-bit integer representing UTF-16 code units.
Why Other Options Are Wrong:
Common Pitfalls:
Confusing char with C/C++ char (which may be signed/unsigned 8-bit depending on compiler), or equating it with short.
Final Answer:
0 to 65535
Discussion & Comments