Java Programming - Language Fundamentals - Discussion

Discussion Forum : Language Fundamentals - General Questions (Q.No. 14)
14.
What is the numerical range of a char?
-128 to 127
-(215) to (215) - 1
0 to 32767
0 to 65535
Answer: Option
Explanation:
A char is really a 16-bit integer behind the scenes, so it supports 216 (from 0 to 65535) values.
Discussion:
19 comments Page 2 of 2.

Suresh said:   1 decade ago
@Arun said is correct why because java supports UNICODE characters that's why character range is 0 to 65535.

Arun said:   1 decade ago
In C as we can use ASCII characters and to represents all ASCII character 8bits enough hence char size is 1 byte.

In JAVA we can use UNICODE characters which cover worldwide all alphabets sets. The no of Unicode characters is >256 and 1byte is not enough so to represent all characters we have to use 2bytes.

The range for 2bytes is 0 to 65535.

Debasish said:   1 decade ago
Hi Guys,
In character data type they (java creators) only considered the unsigned ( +ve) characters unlike in C like languages it was both signed and unsigned.So in C there was 2 ranges for character and integer(signed and unsigned).

Divya said:   1 decade ago
Why is the answer not option B?

The range is determines by -2^n to 2^n-1.

Option B includes the -ve range & D doesn't.

Both are correct according to me.

Prathyusha said:   1 decade ago
In C as it occupies 1 byte its range is -128 to 127 but in Java char occupies 2 bytes so its range is 0 to 65535.

Lavanya said:   1 decade ago
What's the difference between 0 to 32767 and 0 to 65535?

ArJun said:   1 decade ago
Thanks to INDIABIX

EswarReddy said:   1 decade ago
This is good for java students.

V.malarvizhi said:   2 decades ago
What is the numerical rang?

difference between 0 to 32767 and 0 to 65535


Post your comments here:

Your comments will be displayed after verification.