Interview Questions

Suppose I do not want to allow cloning of all objects of a class but based on some condition. What should be done in this case??

Java Interview Questions for Cloning and Cloneable


(Continued from previous question...)

Suppose I do not want to allow cloning of all objects of a class but based on some condition. What should be done in this case??

If the clone should be allowed based on some condition then that condition can be added in the clone method and the exception can be thrown if the condition id not met.

(Continued on next question...)

Other Interview Questions