Tuesday , 7 December 2021
Breaking News
Home » Science/Tech » Newbie point » Difference between Static and Dynamic class loading

Difference between Static and Dynamic class loading

Static class loading:

Classes are statically loaded with Java’s new operator.

Car c= new Car();

A NoClassDefFoundException is thrown if a class is referenced with Java new operator but the runtime system cannot find the referenced class.

Dynamic class loading:
Dynamic loading is a technique for programatically invoking the function of a class loader at runtime. Done by

Class.forName(String className);

The above static method returns the class object associated with the class name.Unlike the static loading the dynamic loading will decide whether to load the class Car or Jeep.Once the class is dynamically loaded the following method reutnrs an instance of the loaded class.It’s just like creating a class object with no arguments.


A classNotFoundException is thrown when an application tries to load in a class through its string name using the following methods but no definition for the class with the specified name could be found:

forName() method in class – Class
findSystemClass() method in class – ClassLoader.
loadClass() method in class – ClassLoader.

Related stories:

Bloodhound supersonic car video
Difference between Stack vs Heap memory
Difference Between C++ and Java