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
how to quit from unlimitedly executing applet

write code employe managment

Outbound Submissions and Tracking: Project Overview: In the current ARISg environment, expedited reports are qualified and distributed electronically to contacts maintaine

Errors: When a dynamic linking failure or some other "hard" failure in the virtual machine happens, the virtual machine gives an Error. Typical Java programs could not find Error

Compare classes with C++ Some significant points to consider when defining a class in java as you probably noticed from above given skeleton are -  There  are  no  global

i have got project of Vending machine. would you please help me about how to start and how to use coding.thanks

What is difference between Design and System Architecture? System architecture is the conceptual design which defines the structure and/or behavior of a system. Whereas designs

A mechanism for converting among string-based markup generated by JavaServer Faces UI components and server-side Java objects.

The program: 2 classes one called Student, one called Grades Functional Requirements: Ask for how many students u need to enter the program must: prompt the user to enter the

WebSphere - Weblogic and Apache: Building/Installation  and maintenance of Solaris and Linux machines. Exposure to Sun Hardware : Sunfire v880,v890.V440,X4600