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 is abstraction in java?

1059


Does java allow overriding static methods ?

1101


What is meant by attribute?

1092


What is static block?

1105


What is final keyword?

1138


What is a method declaration?

972


What is the difference between throw and throws keywords?

1035


What does snprintf return?

984


What if the main() method is declared as private? What happens when the static modifier is removed from the signature of the main() method?

1174


what is daemon thread and which method is used to create the daemon thread? : Java thread

956


What is the main function in java?

1051


How do you control extraneous variables?

902


What happens if we override private method?

954


What is the exact difference in between Unicast and Multicast object? Where will it be used?

1039


Explain 5 features introduced in jdk 1.7?

1006