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

Can a class have multiple subclasses?

1100


When wait(), notify(), notifyall() methods are called does it releases the lock or holds the acquired lock?

997


What is int lol?

1136


Explain the use of sublass in a java program?

1023


Is object a data type?

962


Explain importance of throws keyword in java?

975


What is sortedmap interface?

985


How do I convert a numeric ip address like 192.18.97.39 into a hostname like java.sun.com?

1006


Why do we need singleton class?

999


a thread is runnable, how does that work? : Java thread

1004


Explain try and catch keywords in java?

1201


Explain about main() method in java ?

1063


What is a byte array?

1095


Explain about interthread communication and how it takes place in java?

1019


What does 3 dots mean in java?

981