+92 332 4229 857 99ProjectIdeas@Gmail.com

Data Types (Java)


Data Types:

There are two types:

               Primitive Data Types.
               Object / Reference data types.

Primitive Data Types:

Primitive data types are those which are defined by java, there are 8 data types, let’s have a look on them with some description and examples.

    It is 32-bit signed and unsigned integer
     If you don’t assign some value at initialization of variable then its default value is 0
     For example int a; // now if you print it , it will show you ‘0’ on console

   It is 32-bit and upto 754 decimal floating point number.
     For example float a = 1.2;

   It is 64-bit and upto 754 decimal floating point number.
    For example double a = 1.256;

   It is 16-bit Unicode characters.
    For example char temp = ‘A’;

   It represents true or false.
    For example Boolean result = true;

   It is 64-bit signed integer
    For example long a = 500000;

   It is 16-bit signed integer
    For example short a = 500;

   It is 8-bit signed integer
    For example byte a = 500;

Object / Reference Data Types:

Usually we create reference data types while creating object of class i.e.,

Student st1 = new Student(); // object is created and its reference also


Student st1 = null; // it means object has a reference null