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

Assignment Help:

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


Related Discussions:- Difference b/w deep cloning and shallow cloning of object

Prepare a java program to read .gpx files, Prepare a Java program to read ....

Prepare a Java program to read .GPX files Project Description: Prepare a Java program (GPX_Tracks_to_Text.Java) for Windows to: - Read every .GPX file in a provide drive a

Explain try and catch exception in java, Explain try and catch exception in...

Explain try and catch exception in java? Why use exceptions instead of return values? 1. Forces error checking 2. Cleans up your code through separating the normal case from

Program implement class which have main string method, Implement the Money ...

Implement the Money class discussed in class. This class should represent a dollar and cents amount with 0-99 cents and the cents being the same sign as the dollars. The class shou

Complete the specification of chatter, Tasks: Complete the specifica...

Tasks: Complete the specification of CHATTER, and specify ChatterLists. Implement these ADTs in Java with an abstract class Chatter and a class ChatterList. Use javado

How trojan horses or worms affect a computer system, How Trojan Horses or W...

How Trojan Horses or Worms affect a computer system? What guidelines should be adopted to troubleshoot along with malicious software? Trojan horses are stand-alone programs. Th

Describe the java collections framework? , Comparable interface: The "Com...

Comparable interface: The "Comparable" allows itself to compare with other same types of object. The function compareTo() is specified in the interface. Several of the standa

Describe in general how java garbage collector works, Describe, in general,...

Describe, in general, how java garbage collector works?

Explain subclasses and polymorphism, Explain Subclasses and Polymorphism ? ...

Explain Subclasses and Polymorphism ? Car and Motorcycle are subclasses of MotorVehicle. If you instantiate a Car or a Motorcycle along with new, you can use in which object a

Writing a program with all the primitive, Problem 1 Explain and Define ...

Problem 1 Explain and Define the following concepts with appropriate examples a) Superclass b) Subclass c) Inheritance d) Exceptions e) Stream classes >>Defining and expl

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd