DEV Community

Cover image for what is class in Java?
Arul .A
Arul .A

Posted on

what is class in Java?

-A class is a blueprint used to create objects, defining their structure and behavior.

-A class is a user-defined data type created by the programmer.
It helps model real-world entities in an organized way.

-A class contains variables, methods, constructors, and blocks.
These members together define the complete functionality of an object.

-Memory for a class is loaded once by the ClassLoader into the Method Area.Multiple objects can be created from the same class.

-Objects created from a class are stored in the heap memory.
The reference to the object is stored in the stack memory.

-A class supports encapsulation by bundling data and methods together.

-Classes form the foundation of Object-Oriented Programming in Java.
They enable inheritance, polymorphism, abstraction, and code reusability.

Syntax:

class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)