Give 3 differences between primitive and reference data type.
Answers
Answered by
27
The main difference between primitive and reference type is that primitive type always has a value, it can never be null but reference type can be null, which denotes the absence of value.
primitive types store actual values but reference type stores handle to object in the heap
Reference variables are not pointers but a handle to the object which is created in heap memory.
primitive types store actual values but reference type stores handle to object in the heap
Reference variables are not pointers but a handle to the object which is created in heap memory.
Answered by
56
Primitive data type:
1. These are the data types provided by java
2. The size is fixed
3. To create a variable of primitive type 'new' keyword is not used
Reference data type:
1. These are the data types created by a programmer
2. The size depends on the number of member variables and their types
3. To create a variable of reference type 'new' keyword is used.
1. These are the data types provided by java
2. The size is fixed
3. To create a variable of primitive type 'new' keyword is not used
Reference data type:
1. These are the data types created by a programmer
2. The size depends on the number of member variables and their types
3. To create a variable of reference type 'new' keyword is used.
Similar questions