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

How can u create the Object of class Without using "New"
opertor?

Answer Posted / giridhar gangapatnam

There are 4 ways to create object:

1.using new operator
Employee obj=new Employee();
Except this one

2.using factory methods
NumberFormat obj=NumberFormat.getNumberInstance();

3.using newInstance() method
Class c=Class.forName("Employee");
Employee obj=(Employee)c.newInstance();
or we can write these two lines as a single line
Employee obj=
(Employee)Class.forName("Employee").newInstance();

4.By cloning
Employee obj1=new Employee();
Employee obj2=(Employee)obj1.clone();

Is This Answer Correct ?    20 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Are arrays immutable in java?

1025


How do you initialize an arraylist in java?

991


What are thread safe functions?

905


How do you use compareto in java?

934


Is empty string in java?

1108


What is jvm? How its run?

1030


Mention the default values of all the elements of an array defined as an instance variable.

941


What is the difference between serializable and externalizable interfaces?

1040


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

1356


What is use of static in java?

1112


What is definition and declaration?

970


In which language java is written?

935


What is the null?

959


Do I need java on my computer?

933


What is keyword in oop?

921