What is the numerical range of char?

  1. 0 to 32767

  2. 0 to 65535

  3. -256 to 255

  4. -32768 to 32767


Correct Option: B

AI Explanation

To answer this question, we need to understand the numerical range of the char data type.

In Java, the char data type represents a single character and is stored as a 16-bit unsigned integer. The numerical range of char is from 0 to 65535.

Let's go through each option to understand why it is correct or incorrect:

Option A) 0 to 32767 - This option is incorrect because it does not cover the full range of char values.

Option B) 0 to 65535 - This option is correct because it represents the full numerical range of the char data type.

Option C) -256 to 255 - This option is incorrect because it does not cover the positive range of char values.

Option D) -32768 to 32767 - This option is incorrect because it includes negative values, while char is an unsigned data type.

The correct answer is Option B. This option is correct because it represents the full numerical range of the char data type, which is from 0 to 65535.

Find more quizzes: