What is the numerical range of a char?

By Anjnee Bhatnagar|Updated : June 28th, 2022

What is the numerical range of a char?

  1. 0 to 32767
  2. 0 to 65535
  3. -256 to 255
  4. -32768 to 32767

Answer: Option B. 0 to 65535

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:

Comments

write a comment

Follow us for latest updates