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
Due to impedance mismatch between relational technology and object you need to understand the progress of mapping classes (objects) and their relationships to tables and relationsh

Why are JSP pages the preferred API for creating a web-based client program? Because no plug-ins or security policy files are required on the client systems (applet does). Also,

What is the name of the services you have chosen? What do they do? What is the name of the publisher? Provide details if you are developing your own service(s). There are variou

In Exercise 1 you were asked to modify the Sorts program so that it would output the number of swaps used by a sorting method. It is a little more difficult to have the program als

In this lab, you will practice using ArrayLists in two ways.  The first is in the problem domain class Question.java (see the UML diagram shown below) which contains data for trivi

Project Description: Give a script that will produce a pop-under on a mobile landing page -We can host our own landing page and we will want to change the destination URL for

Your class must contain the followings (20 points):Code a simple class in JAVA classed “Student. · Variables (name, age, addressStreet, city, state, zip, country) ·

Write a program called LandThePlane that calculates whether a plane successfully lands or not.   The program begins by prompting (asking) the user for the following details, in th

BeanFactory has many executions in Spring. But one of the most useful one is org.springframework.beans.factory.xml.XmlBeanFactory, which loads its beans based on the definitions ha

Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4