Interview Questions

What is the difference between cloneable and serialization of an object?

Java Interview Questions for Cloning and Cloneable


(Continued from previous question...)

What is the difference between cloneable and serialization of an object?

These are Marker interface,and both are different action ,no comparasion between then

Clonable interface is used to make a clone of a object,every time create a new instance by new operator is costly in terms of JVM ,resource & performace. so we can create similiar type of instance with the help of already been created instance by using clone()

Serialization is a process to convert your object into bitstream and send accross the network and deserialze at other end,process like Marshling.used in client-server archicture To understand the difference between clone and serialization, initially you should understand the difference between Deep Copy and Shallow Copy.

In the java doc API for clone() of Object class, it is clearly mentioned that clone is a shallow copy and not deep copy.

Serialization indirectly does the Deep copy.

(Continued on next question...)

Other Interview Questions