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 cloneable interface?

Answer Posted / saravanan sagadevan

clonable interface is a marker interface to clone the
object.If we want to clone the object then we have to
override clone method .

public Object clone() throws CloneNotSupportedException(){
try{
super.clone();
}catch(CloneNotSupportedException exe){


}
There are two types of clone 1. Shallow copy 2.Deep copy

1. Shallow Copy:
Default copy is shallow copy . Ex :

Class Person {
private Car car ;
public Car getCar(){
this.car=car
}
public Object clone() throws CloneNotSupportedException
(){
try{
super.clone();
}catch(CloneNotSupportedException exe){


}
When Person object is copied, new perosn object will be
created , but Member object car is shared by both copies.
If you make changes in Car object that will be reflected in
cloned object also.

Deep Copy:
===========
For Deep copy , seprate Parent(Person) and child object
will be created .There two copies will be created

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is space character in java?

1038


Is java developer a good career?

964


Should you use singleton pattern?

900


Is main a function?

964


Explain the advantages of packages in java?

861


Which eclipse is best for java?

958


What do you mean by thread safe?

929


What is methodological theory?

932


What will happen if a thrown exception is not handled?

955


how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? : Java thread

958


What are the two environment variables that must be set in order to run any java programs?

908


Where pragma is used?

992


How can we create a thread in java?

968


how can you catch multiple exceptions in java?

971


What are keywords in java?

949