Samsung Interview Question
Software Engineer / DevelopersThis is not the proper answer.
Shallow copy: In this type of copy only primitive members of the objects are copied. In this case cloned object refer to the same object for which clone has been invoked, as only the reference is copied not the whole object.
Deep copy: In the deep copy member objects are also copied along with the primitive types, to support deep copy we need to override the clone method of Object class, because in original clone() method it is not supported as it is defined in Object class and and at that level we don't know whether our class will have any non-primitive member or not.
very simple :)
- seeker7 July 05, 2010shallow copy refers when we pass parameters by reference and deep copy is passing by value,it is deep since we make a copy of the argument passed.