DEV Community

Ashwin vijay
Ashwin vijay

Posted on

What is class?

In Java, classes and objects form the foundation of Object-Oriented Programming (OOP). They help model real-world entities and organize code in a structured way.

  • A class is a blueprint used to create objects that share common properties and behavior.

  • An object is an instance of a class. It represents a specific entity created from the class template.
    For Example, Dog is a class, Tommy is an object of that class.

Java class
A class is a blueprint that defines data and behavior for objects. It groups related fields and methods in a single unit. Memory for its members is allocated only when an object is created.

  • Acts as a template to create objects with shared structure.

  • Does not occupy memory for fields until instantiation

  • Can contain fields, methods, constructors, nested classes and interfaces.

Top comments (0)