Multiple choice technology programming languages

What is the range of values that can be assigned to a variable of type byte?

  1. It depends on the underlying hardware

  2. 0 through 28–1

  3. 0 through 216–1

  4. –27 through 27–1

  5. –215 through 215–1

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

A Java byte is a signed 8-bit integer, which can represent 256 different values. These range from -128 to 127, calculated as -2^7 to 2^7-1. Options B and C incorrectly show unsigned ranges, and option E describes a short (16-bit), not a byte. Java primitive types have fixed sizes regardless of the underlying hardware.