What is the numerical range of a char?

  1. -128 to 127

  2. -(215) to (215) - 1

  3. 0 to 32767

  4. 0 to 65535


Correct Option: D

AI Explanation

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

In most programming languages, including Java and C++, a char data type represents a single character and is stored as a 16-bit value.

The correct answer is D) 0 to 65535. This is because a char data type can store values between 0 and 65535, inclusive. The range starts from 0 because it represents the Unicode value for the character '0', and it goes up to 65535 because it represents the maximum Unicode value that can be stored in a char.

Option A) -128 to 127 is incorrect because this range corresponds to the numerical range of a byte data type, which is 8 bits in size.

Option B) -(2^15) to (2^15) - 1 is incorrect because this range corresponds to the numerical range of a short data type, which is 16 bits in size.

Option C) 0 to 32767 is incorrect because this range corresponds to the numerical range of an int data type, which is typically 32 bits in size.

Therefore, the correct answer is D) 0 to 65535.

Find more quizzes: