Create Object Using Clone

Give an example of using clone to create an object.

Questions by pragya03

Showing Answers 1 - 6 of 6 Answers

We can create an object by using clone() method which is a object class method.

Create an object like

MyClass obj=new MyClass();

CloneClass cloneobj=(CloneClass)obj.clone();

By this way you can create a copy of an object using obj.clone() method.But you should typecast the object to another class of object.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions