Difference between static and dynamic class loading.
Static class loading:This is done by using Java’s new operator.
For Example: class myprogram
{
public static void main(String args[ ])
{
program1 b =new program1();
}
}
A NoClassDefFoundException is thrown if a class is referenced with Java’s “new”operator (i.e. static loading) but the runtime system cannot find the referenced class.
Dynamic class loading:This is done by programmatically invoking the functions of a class loader at run time.
Class.forName (String className);
static method which returns a Class
The above static method returns the class object associated with the class name.
The string className can be supplied dynamically at run time. class.newInstance ();
A non-static method, which creates an instance of a class (i.e. creates an object).