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
Implicit objects are formed by the web container and have information related to a particular request, page, or application. They are request, response, pageContext, session, appli

What are the advantages that Java's layout managers provide over traditional windowing systems ?

what is methods override?

What are the conditions for exiting the while loop?

Write a ComputerPart class and a ComputerKit class and a client class to test them. The ComputerPart class has two variables: a String representing an item, and a double representi

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

hi,i need whatsapp panel to send unlimitd message. skype : maya123.com email :

How can we involve images within a web page using HTML and Java script? Images can be included in HTML through employing tag, below is the format of

A preconfigured JMS object (a resource manager connection factory or a destination) formed by an administrator for the use of JMS clients and placed in a JNDI namespace

Explain the difference between pre-emptive scheduling and time slicing ?