0 votes
in JAVA by

What is object cloning?

3 Answers

0 votes
by

 What is object cloning?

1) Object cloning is the process of creating an exact copy of an object of a class. The state of the newly created object is the same as the object used for cloning.

2) The clone() method is used to clone objects. The cloning done using the clone method is an example of a deep copy.

0 votes
by
The object cloning is a way to create an exact copy of an object. The clone() method of the Object class is used to clone an object. The java.lang.Cloneable interface must be implemented by the class whose object clone we want to create. If we don't implement Cloneable interface, clone() method generates CloneNotSupportedException. The clone() method is defined in the Object class. The syntax of the clone() method is as follows:

protected Object clone() throws CloneNotSupportedException
0 votes
by
An ability to recreate an object entirely similar to an existing object is known as Object Cloning in Java. Java provides a clone() method to clone a current object offering the same functionality as the original object.

Related questions

+1 vote
asked May 5, 2021 in JAVA by SakshiSharma
0 votes
asked Apr 9, 2021 in JAVA by Robindeniel
...