Javatpoint Logo

objects

By: chandr*** On: Sat Mar 25 20:50:06 IST 2017     Question Reputation0 Answer Reputation0 Quiz Belt Series Points0  0Blank User
How Many Ways Object Creation ?Up0Down

 
2Image Created0Down

By: [email protected] On: Mon Mar 27 14:58:23 IST 2017 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No
 
A. Using new keyword
This is the most common way to create an object in java.

B. Using Class.forName()
If we know the name of the class & if it has a public default constructor we can create an object in this way.
MyObject object = (MyObject) Class.forName("subin.rnd.MyObject").newInstance();

C. Using clone()
The clone() can be used to create a copy of an existing object.
MyObject anotherObject = new MyObject();
MyObject object = (MyObject) anotherObject.clone();

D. Using object deserialization
Object deserialization is nothing but creating an object from its serialized form.
Image Created0Down

By: [email protected] On: Mon Mar 27 15:41:40 IST 2017 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No