Deep v/s Shallow Copying

By deafult when you create a clone of any object the shallo w copy is created
class MyClass{

int dummyint;
XYZ dummyreference;

}

When you create a clone of object if that object consist of only instance variable of primitive types a new object is created with the same value and reference to this new object is returned But if the object consist of some refernce variables then the value of variables are just copied

copy1

thus any changes made by cloned object will effect the other also

But with a deep Copy an entirely new object is returned all the classes that are involved must be clonnable and if they do not support clonning the clone method must return a new instance of the object,  A new instance of that class that do not support clonning will be created  and you need to copy all its attributes one by one  This object will be returned and set as clonned object

copy1

Thus any changes made by clonnedObject.dummyreference will have no impact on object.dummyreference