Java OCA OCP Practice Question 985

Question

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

  • A. Depends on the underlying hardware
  • B. 0 through 2^16 - 1
  • C. 0 through 2^32 - 1
  • D. -2^15 through 2^15 - 1
  • E. -2^31 through 2^31 - 1


D.

Note

The range for a 16-bit short is -2^15 through 2^15 - 1.

This range is part of the Java specification, regardless of the underlying hardware.




PreviousNext

Related