Difference b/w deep cloning and shallow cloning of object, JAVA Programming

The default nature of an object's clone() function automatically provides a shallow copy. So to need a deep copy the classes have to be edited or adjusted.

 

Shallow copy: If a shallow copy is operated on obj-1 as shown in fig then it is copied but its contained objects are not copied. The contained objects Obj-2 and Obj-1 are affected by modifies to cloned Obj-2. Java use shallow cloning of objects by default when a class implements the java.lang.Cloneable interface.

 

Deep copy: If a deep copy is operated on obj-1 as shown in fig then not only obj-1 has been copied but the objects properties also copied as well. Serialization may be used to achieve deep cloning. Deep cloning through serialization is faster to deploy and easier to maintain but carries a performance overhead.

 

 

1520_Untitled.png

Posted Date: 7/25/2012 2:08:39 AM | Location : United States







Related Discussions:- Difference b/w deep cloning and shallow cloning of object, Assignment Help, Ask Question on Difference b/w deep cloning and shallow cloning of object, Get Answer, Expert's Help, Difference b/w deep cloning and shallow cloning of object Discussions

Write discussion on Difference b/w deep cloning and shallow cloning of object
Your posts are moderated
Related Questions
Very frequently when you write code, you desire to perform distinct actions for different decisions. You can employ conditional statements in your code to do this. In JavaScript

A user interface control that outputs data to a client or permits a user to input data to a JavaServer Faces application.

write a program in java using array and scanner class to generate padovan series

How to Drawing Images at Actual Size Once the image is loaded draw it in the paint() method by using the drawImage() method like this g.drawImage(img, x, y, io) img is a

How to Scaling Images in java applet? You can scale an image within a particular rectangle using this version of the drawImage() method: public boolean drawImage(Image img,

.Write a programme to create a webpage that prints the name of the STUDENT database in Wide Latin font and set the subtitle with description of the STUDENT to the screen. Set the

The roster lets you keep track of the availability ("presence") of other users. A roster also allows you to organize users into groups such as "Friends" and "Co-workers". Other IM

Question : (a) Explain the concept of polymorphism when used in programs using suitable examples of your own. (b) (i) Distinguish between abstract methods and non-abstrac

Mine craft plug-in Coder Project Description: Some custom plugging for my Mine craft server. Skills required: Java, Editing

Explain The Methods of java.lang.Object? java.lang.Object gives a number of methods that are general to all objects. toString() is the most general such method. Because the def