Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


what is class.forname() and how it will be useful ?

Answers were Sorted based on User's Feedback



what is class.forname() and how it will be useful ?..

Answer / amit singh

it is useful when you don't know about the class as compile
time you must to use it you pass the class name as a string
and
its a part of reflection api
but you used it when you connect through db
and many more you should do when you don't know the class
at compile time
and also above which mention by pradip right
amitsingh200@gmail.com
amit09mca(scjp 1.5 and manymore)

Is This Answer Correct ?    5 Yes 0 No

what is class.forname() and how it will be useful ?..

Answer / pradip

class.forname() is used to create an instance of a class on
the basis of the name in string format instead of doing new
Class. One of its use is in cases where you have some
generic (common) logic to call methods of some classes just
on the basis of the names of the class and the method. The
example of reflection shown below uses the logic.

Eg:
performAction(String className, String methodName) {
Class class = Class.forName(className);
MethodUtils.invokeMethod(class.newInstance, methodName,
null);
}

Is This Answer Correct ?    3 Yes 0 No

what is class.forname() and how it will be useful ?..

Answer / keerthi

In java we are using class.forName("classname")in jdbc
for creating instance of driverclass at the same to
registering with drivermanager.

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More Core Java Interview Questions

How many JVMs can run on a single machine and what is the Just-In-Time(JIT) compiler?

0 Answers   Global Logic,


What is meant by Java interpreter?

4 Answers  


AWT event listeners extends what interface?

1 Answers  


What is array size in java?

0 Answers  


Which all r Final classes in java except string?

5 Answers   HCL,


What is the replace tool?

0 Answers  


What is jrmp?

0 Answers  


What is Three tier architecture. Can anyone explain with a Ordinary web application Project? (JSP,Servlets,JAVA,DAO) ?

3 Answers   TCS,


What is class level lock ?

0 Answers  


Can we use synchronized block for primitives?

0 Answers  


Difference between doublesummarystatistics, intsummarystatistics and longsummarystatistics ?

0 Answers  


What are the changes in java.io in java 8 ?

0 Answers  


Categories