Can you refer to a class as a composite type / user-defined type?

Short Answer
Views 50

Answer:

✅ Yes.

  • A class is composite because it groups together multiple variables (fields) and methods.

  • A class is also a user-defined type because it is defined by the programmer (not provided as a built-in primitive).

Example:


class Book {
    String title;    // field
    String author;   // field
    int pages;       // field
}

Book is both:

  • A composite type (made up of String and int)

  • A user-defined type (created by the programmer).

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.