Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is d difference between deep cloning and shallow
cloning in core java?

Answer Posted / sunny

Deep cloning - You clone the object and their constituent parts.

This kind of cloning is adequated when the parts of the
object make up the object, and can not be separated from it.

A car HAS four wheels, and to clone (copy) a car, I must
clone their four wheels.

Shallow cloning - You clone only the object, not their
parts. You add references to their parts.

This kind of cloning is adequated when the parts of the
object are independent of it.

An entry in an address book has the street name, the city
name. To clone that entry, you simply add references to the
street and city names.

That distinction is a little difficult to be done in Java,
but is better understood if you think in terms of databases.

You need deep cloning if the entity requires "cascade
deleting" to be deleted. You need shallow cloning if
"cascade deleting" is not needed.

Is This Answer Correct ?    28 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What's the difference between an abstract class and interface in java?

1040


Can we override static methods in java?

1080


why Java does not support multiple inheritances?

1175


How do generics work?

952


How does remove work in java?

984


What is a map in java?

999


What are the legal operands of the instanceof operator?

1037


Can one thread block the other thread?

1038


Can we have a method name same as class name in java?

1062


Which method you will use to create a new file to store some log data. Each time a new log entry is necessary, write string to the file in java ?

1168


What is jit compiler ?

987


How can constructor chaining be done by using the super keyword?

1097


Why declare Main() method as a static in java ?

1089


What is a container in a gui?

1000


How is java hashmap implemented?

1036