clone() method is available in Object class so can all objects of every class be cloned?
Java Interview Questions for Cloning and Cloneable
(Continued from previous question...)
clone() method is available in Object class so can all objects of every class be cloned?
No, by default clone() method throws CloneNotSupported exception when it is invoked on an object of a class not implementing Cloneable interface. So to make the objects of a class cloneable, it should implement the Cloneable interface.
(Continued on next question...)
Other Interview Questions
|