Im having trouble invoking methods on the objects returned from Classs forName method-how should I use Class.forName?
Ans : Invoke newInstance on the Class object returned by forName and then cast the resulting instance to a type that the compiler can access; only then can your program invoke a method on the instance of the newly loaded class. The forName method in class Class is a hidden gem in the Java system. This method lets your code create a new class type from a dynamic name—that is, a name given to your program as a string at run time. What’s particularly powerful about using forName is that neither you nor the compiler needs to know the exact details of the new class, only what superclass it extends or interfaces it implements. The forName method is what enables a Java-capable browser, for instance, to load arbitrary applets, even though the browser can’t know in advance what Applet subclasses it will be called on to create. The forName method takes a String argument as the name of a class, and attempts to create a binary representation for a class with that name. (This process is called clas