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

What is multithreading in java?

761


What is method overloading with type promotion?

904


Can abstract class have private constructor?

695


How do you sort a string in alphabetical order in java?

732


What does nextint () do in java?

749


What is a memory leak in java?

765


How to convert string to char and vice versa?

717


Is null a value?

774


How do you reverse a word in java?

735


What is the purpose of static methods and static variables?

743


Can I declare class as static or private?

740


What is basic syntax?

737


Can Exception handling we can handle multiple catch blocks?

817


How many types of the indexof method are there for strings?

706


How does a for loop work java?

763