-
What is the range of byte data type in Java?
-
- -128 to 127
- -32768 to 32767
- -2147483648 to 2147483647
- None of the mentioned
- NA
Correct Option: A
Byte occupies 8 bits in memory. We use the formula - 2(bits-1) to calculate the negative range, and we use 2(bits-1)–1 for the positive range.
So byte range is from - 2(8-1) to 2(8-1) -1 which is -128 to 127.