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

Is object a data type?

950


What is the difference between applet and application?

993


How do I get a substring?

955


How can you make sure that your singleton class will always return single instance in multi-threaded environment?

1004


What is overloading and overriding in java?

1200


What is a for loop in java?

1029


Which is easier netbeans or eclipse?

1049


What are accessor methods in java?

983


What is ctrl m character?

1039


what r advatages of websphere? & how to deploy?

2168


What is the requirement of thread in java?

1027


Compare java and python.

964


When throw keyword is used?

1050


What is the default value of the local variables?

1001


What is difference between static variable and global variable?

1039