Posts

Showing posts with the label Java Memory Management

Class Loading in Java: Explicit vs Implicit Class Loading with Examples

🔄 Class Loading in Java – Complete Beginner Guide What is Class Loading in Java? Class Loading is the process by which the Java Virtual Machine (JVM) loads a .class file from the hard disk into the JVM memory (Method Area / Class Area) during program execution. Without class loading, Java classes cannot be executed. Types of Class Loading in Java Class loading in Java is broadly classified into two types: Explicit Class Loading Implicit Class Loading 1️⃣ Explicit Class Loading What is Explicit Class Loading? Explicit class loading occurs when the JVM loads a class automatically because the programmer directly accesses any class member. When Does Explicit Class Loading Happen? Accessing a static variable Calling a static method Creating an object using constructor Example: Student s = new Student(); // Class loaded explicitly ✔ The JVM loads the Student.class file when the object is created. 2️⃣ Implicit Class Loading What is Implicit Class Loading? Implicit class loading is a process ...