why 1st code is executed but 2nd gives the CloneNotSupportedException

  • class test {
    public static void main(String as[]){
    Hello h=new Hello();
    Object obj=h.clone();
    class Hello{
    protected Object clone(){
    return this;
    //it is working without implementing interface

Source: java

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.