Problem Statement
What is the difference between shallow copy and deep copy of objects? Give examples.
Explanation
A shallow copy duplicates the object but shares references of internal mutable objects; modifications in one reflect in the other. A deep copy duplicates the object and its entire internal structure so changes in one don’t affect the other. In C++ copy constructor or clone methods handle copying; in Java you might implement Cloneable or use serialization. Explaining pitfalls and when each is needed shows depth.