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

Short Answer
Views 47

Answer:

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.

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.