WHAT IS THE CONCEPT OF CLONING IN JAVA - TopicsExpress



          

WHAT IS THE CONCEPT OF CLONING IN JAVA ? ====================================================== -->Cloning an object is nothing but making an identical copy of an existing object .(i.e making a duplicate copy of existing object). -->After cloning, the original object & cloned object contains separate memories . -->To perform the cloning on a class object , that class must implement the “Clonable” interface which is present in “java.lang” package. -->”java.lang.Clonable” interface is a MARKER interface( Marker means the interface which contains null body or empty body . And the purpose of marker interface is to give indication to JVM). Eg:- public class Students implements Clonable { Public Object clone() throws ClassNotFountException { } } Q) HOW MANY TYPES OF CLONING ? -->1)shallow cloning 2)deap cloning Q)WHAT IS SHALLOW CLONING & DEAP CLONING? -->in shallow cloning only primitive properties(i.e int,float,double,char,short,byte,long,)are cloned, but reference types(like class reference ,array,collection etc...) are not cloned. -->in deap cloning all primitive as well as referenced data types are cloned more@JAVA Knowledge
Posted on: Sat, 16 Aug 2014 18:30:41 +0000

Trending Topics



Recently Viewed Topics




© 2015