Interview Questions

What is the different ways to create object clones?

Java Interview Questions for Cloning and Cloneable


(Continued from previous question...)

What is the different ways to create object clones?

Cloning is of two types viz shallow and deep cloning. Shallow cloning is what the default behavior of clone method is and deep cloning is achieved by overriding the clone method in a class.
With shallow cloning the member primitive variables are also cloned but the member reference variables are not cloned. This means that the reference variables referring to objects are shared between the original and cloned objects.

(Continued on next question...)

Other Interview Questions