J2EEOnline J2EE






Java Certification  «Prev  Next»
Lesson 6Primitive Types
ObjectivePrimitive types and range of values

Primitive types in Java

Describe the primitive types and range of values associated with each type.
Java variables may store the values of primitive types or references to objects. Java supports the following eight primitive types:
  1. boolean - Consists of the boolean values true and false.
  2. byte - Supports 8-bit integer values from -128 to 127.
  3. char - Supports 16-bit Unicode characters whose values range from 0 to 216 - 1.
  4. short - Supports 16-bit integer values whose values range from -(215) to 215 - 1.
  5. int - Supports 32-bit integer values whose values range from -(231) to 231 - 1.
  6. long - Supports 64-bit integer values whose values range from -(263) to 263 - 1.
  7. float - Supports 32-bit floating point values whose values range from Float.MIN_VALUE to Float.MAX_VALUE. It also includes the values Float.NaN (not a number), Float.NEGATIVE_INFINITY, and Float.POSITIVE_INFINITY.
  8. double - Supports 64-bit floating point values whose values range from Double.MIN_VALUE to Double.MAX_VALUE. It also includes the value Double.NaN (not a number), Double.NEGATIVE_INFINITY, and Double.POSITIVE_INFINITY.


The NaN (not a number) value is used with floating point types to indicate the result of an undefined mathematical operation.
The values POSITIVE_INFINITY and NEGATIVE_INFINITY are used to represent infinite values.
Unicode: A 16-bit character set that includes ASCII and provides support for international characters.
Remember the ranges of each of the primitive types. You will see questions on the certification exam that test your knowledge of them.