Interview Questions

Give an example code for both shallow and deep cloning?

Java Interview Questions for Cloning and Cloneable


(Continued from previous question...)

Give an example code for both shallow and deep cloning?

Suppose you have imported both java.util and java.sql packages into your program and you wish to use a Date class.
This would create a conflict because both the packages have a Date class. To overcome this, give a fully qualified name when using the Date class.
For example:
java.util.Date d= new java.util.Date();

(Continued on next question...)

Other Interview Questions