Home / Questions / What is a composite datatype? What is a user-defined datatype?
Explanatory Question

What is a composite datatype? What is a user-defined datatype?

👁 50 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

Composite datatype:
A datatype that is made up of multiple values or other datatypes.
Examples in Java:

  • Array → collection of same type of data.

  • Class/Objects → bundle of variables + methods.

  • String → technically an object that holds a sequence of characters.


int[] marks = {90, 85, 70}; // Array = composite datatype

User-defined datatype:
A datatype that is created by the programmer using classes, interfaces, or enums.
Example:


class Student {
    String name;
    int age;
}

Here, Student is a user-defined datatype.