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();
    Sop(obj==h);
    }
    }
    class Hello{
    protected Object clone(){
    return this;
    }
    }
    //it is working without implementing interface


Source: java

Leave a Reply