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...

There are 2 different ways to create an object. a)By using
keyword "new" b)By using Class.forName
("className").newInstance();
What is the difference between these 2 methods.

Answer Posted / aslam

If we know the class name during the compile time, we must
use the keyword "new". because this creates much faster
than the second method. But if we get the class name only
on run time, we have to use Class.forName
("classNameAsArgument").newInstance(); Here we can pass the
class name as a string argument. We can't achieve this with
the keyword "new".

Is This Answer Correct ?    17 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between stream and buffer?

971


Does apple use java?

958


Can there be an abstract method without an abstract class?

964


Explain java thread life cycle.

1046


What are the differences between c++ and java?

1144


What does i ++ mean in Java?

960


Explain the importance of finally over return statement?

1046


What is string and example?

1048


What do you know about java?

957


What do you mean by boolean?

1067


What is stream api in java8?

1192


Explain about interthread communication and how it takes place in java?

1030


What is the difference between yielding and sleeping?

1119


Can you declare an interface method static?

1068


Is void a data type in java?

996