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


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

A. It depends on the underlying hardware.

B. 0 through 216-1

C. 0 through 232-1

D. -21515 through 215-1

E. -231 through 231-1.

Answer:D is correct. The range for a 16-bit short is -215 through 215-1. This range is part of the Java specification, regardless of the underlying hardware.

 

 

 

 

 
 
 
 
 
COPYRIGHT © 2017 java-samples.com. ALL RIGHTS RESERVED.