when we write class.forName("any one class"); what happens
actually?what it will return?explain stepwise?

Answer Posted / paras

Class.forName("")loads that class in memory ,to create
instance we have to use newInstance()

string _path="classpath loc of class XYZ ex com.aa.ss.XYZ";

Object ob=Class.forName(_path).newInstance();;
((XYZ)ob).any_method_of_XYZ();

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why isn’t there operator overloading?

613


Explain the difference between abstract classes and interfaces in java?

606


Is an empty arraylist null?

607


How an object is serialized in java?

542


What is an array in java?

646






What is the history of java?

556


What is a classloader in java?

538


Can a abstract class be declared final?

577


How do you decide when to use arraylist and linkedlist?

540


What is the significance of java packages?

624


What is the java reflection api? Why it’s so important to have?

567


Can we have any code between try and finally blocks?

568


What is the difference between logical data independence and physical data independence?

548


What is this keyword used for?

699


How do you override a method?

557