What is the numerical range of a char?
By BYJU'S Exam Prep
Updated on: September 25th, 2023
What is the numerical range of a char?
- 0 to 32767
- 0 to 65535
- -256 to 255
- -32768 to 32767
Answer: Option B. 0 to 65535
Table of content
0 to 65535 is the numerical range of a char for Java.
Solution
The character type or char is an unsigned integer. Char ranges from 0 to 216-1. Irrespective of the language. Every language has a different range for different data types. Like in C, the range for char type is -128 to 127. Java uses Unicode, a 16-bit encoding that may represent a large number of different international characters. The encoding is identical to seven-bit ASCII if the most significant nine bits of a character are zero. Hence, the answer to the above question is that 0 to 65535 is the numerical range of a char.
☛ Related Questions: