Organizational Research By

Surprising Reserch Topic

How many ways you can copy one object properties to another?



asked Sep 13, 2013 in Core java by rajesh
edited Sep 12, 2013
0 votes
29 views



Related Hot Questions

2 Answers

0 votes
Copying an object involves getting another object with the same properties of the original. Here, there exists two ways – two objects having their own set of properties (instance variables) or both objects referring the same location of properties. Following gives the detailed discussion.
 
Shallow Copying
 
Shallow copying is the easier of the two styles; here, one object is assigned with another. When assigned, both objects refer the same location of variables. When both objects refer or share the same location, the minus point is if one object changes the value, the other object also gets affected. That is, to say straight is no encapsulation exists. One small advantage is memory is less used.
answered Sep 13, 2013 by rajesh
edited Sep 12, 2013
0 votes
3 ways – Shallow copying, Deep copying and Cloning.
answered Sep 13, 2013 by rajesh
edited Sep 12, 2013

...