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.
|