Let us Assume an object- obj1, that contains two objects, containedObj1 and containedObj2.
shallow copying:
shallow copying creates a new instance of the same class and copies all the fields to the new instance and returns it. Object class provides a clone method and provides support for the shallow copying.
Deep copying:
A deep copy occurs when an object is copied along with the objects to which it refers. obj1 after a deep copy has been performed on it. Not only has obj1 been copied, but the objects contained within it have been copied as well. We can use Java Object Serialization to make a deep copy. Unfortunately, this approach has some problems too(detailed examples).