InterviewSolution
| 1. |
What Is Difference Between Shallow Copy And Deep Copy? Which Is Default? |
|
Answer» When you do a shallow copy, all the fields of the source object is copied to target object as it is. That means, if there is a dynamically created FIELD in the source object, shallow copy will copy the same pointer to target object. So you will have TWO OBJECTS with fields that are pointing to same memory location which is not what you usually want. When you do a shallow copy, all the fields of the source object is copied to target object as it is. That means, if there is a dynamically created field in the source object, shallow copy will copy the same pointer to target object. So you will have two objects with fields that are pointing to same memory location which is not what you usually want. |
|