Difference between static and dynamic class loading.

Explain the difference between static and dynamic class loading.

1. The static class loading is done through the new operator.
2. Dynamic class loading is achieved through Run time type identification,also called as reflection.
3. This is done with the help of the following methods:
getClass(); getName(); getDeclaredFields();
4. Instance can also be created using forName() method. It loads the class into the current class memory.

What is static and dynamic class loading in Java?

Static Class Loading: Creating objects and instance using new keyword is known as static class loading. The retrieval of class definition and instantiation of the object is done at compile time.

Dynamic Class Loading: Loading classes use Class.forName () method. Dynamic class loading is done when the name of the class is not known at compile time.
Java Comparator Interface: What is the purpose of Comparator Interface?
Java Comparator Interface - Comparators can be used to control the order of certain data structures and collection of objets too...
Java autoboxing and unboxing - Explain autoboxing and unboxing.
Java autoboxing and unboxing - Explain autoboxing and unboxing, What is Auto boxing and unboxing?...
What is Map and SortedMap interface?
Java Map and SortedMap - Maps are used to store the key-Value pairs...
Post your comment
Discussion Board
Static and Dynamic Class Loading in JAVA
Static Class Loading: Classes are statically loaded with Java’s “new” operator. NoClassDefFoundException is thrown If a class is available at compile time, but not at run time.

Dynamic Class Loading: Dynamic loading is a technique for programmatically invoking the functions of a class loader at run time using any of the below methods
Class.forName(String) or ClassLoader.findSystemClass(String) or ClassLoader.loadClass(String). A ClassNotFoundException is thrown if the requested class definition is not found.
Laxmikanth Rajuri 05-8-2013
Static and Dynamic Class Loading
In static loading, classes are loaded during JVM start up. Dynamic loading is done during run time by requesting JVM to load a class using forName()
Laxmikanth 05-8-2013