Data Types in Java ( Part 2)

#.  Why do we have  8 Primitive data type?
Based on type and range of data ,primitive  types are divided into 8 types.

#.   Why do we have  4  referenced data type?
To collect same type of values of Array is given and to collect different type of values class,interface and enum are given.

JVM creates memory location based on the data type size,names that ML with the given name,and stores the assigned value in the memory location . This named memory location is technically called variable.

Example: 

class DataTypesDemo{ 
 //primitive type variable creation  

         byte b =10; int i =20; char ch ='a';

    //Array type variable creation 
       
         double[] d ={1,2,3,4,5};

    //predefined class string type variable creation 

         String str = "Hari";

       public static void main(String [] args) 
     { </br>

         //User defined class DataTypeDemo variable creation

           DataTypesDemo dd=new DataTypesDemo(); 

Comments :

Post a Comment