There are two data types available in Java:
- Primitive Data Types
- Reference/Object Data Types
a) Primitive Data Types :
There are eight primitive data types supported by Java. Primitive data types are predefined by the language and named by a key word Let us now look into detail about the eight primitive data types.
Primitive Data Types:
Data Type | Memory Size | Default Value | Declaration | Range |
byte | 8 bits | 0 | byte a = 9; | -128 to 127 |
short | 16 bits | 0 | short b = 89; | -32768 to 32767 |
int | 32 bits | 0 | int c = 24; | -2147483648 to 2147483647 |
long | 64 bits | 0 | long d = 985465; | -9223372036854775808 to 9223372036854775807 |
float | 32 bits | 0.0f | float e = 87.36f; | +/- 1.4023×10-45 to 3.4028×10+38 |
double | 64 bits | 0.0 | double f = 85.454; | +/-4.9406×10-324 to 1.7977×10308 |
char | 16 bits | ‘ u0000 ‘ | char g = ‘c’ ; | 0 to 65535 |
boolean | JVM Dependent | false | boolean h = true ; |
b) Reference Data Types:
- Reference variables are created using defined constructors of the classes. They are used to access objects. These variable are declared to be of a specific type that cannot be changed For example, Employee, Puppy etc.
- Class objects, and various type of array variables come unde reference data type.
- Default value of any reference variable is null.
- A reference variable can be used to refer to any object of the declared type or any compatible type.
- Example: Animal animal = new Animal(“giraffe”);
Java Literals:
A literal is a source code representation of a fixed value. They are represented directly in the code without any computation.
Literals can be assigned to any primitive type variable.
For example:
byte a = 68;
char a = ‘A’
Escape Sequences :
Definition : A character preceded by a backslash (\) is an escape sequence and has special meaning to the compiler. The following table shows the Java escape sequences: Escape Sequences .

