Computer Applications
What do you understand by primitive and non-primitive data types? Give an example of each.
Values & Data Types Java
11 Likes
Answer
A primitive data type is predefined by the Java language and is named by a reserved word. Java defines 8 primitive data types — byte, short, int, long, float, double, char, boolean.
For example,
int a = 10;
Here, data type of variable a is the primitive type int.
A number of primitive data types are used together to represent a non-primitive data type. Array, Class and interface are examples of non-primitive data type.
For example,
int arr[] = {1, 2, 3, 4};
Here, data type of variable arr is an int array which is a reference type.
Answered By
6 Likes