I am trying to pass OCP 8 and I face this code which can override a class method on the fly as it treats it as abstract or interface
package xxx.xxx.ClassC;
public class ClassC{
public void print(){`enter code here`
System.out.println("ClassC method implementation");
}
}
package yyy.yyy.ClassB;
public class ClassB{
public static void main(String[] args){
ClassC ref=new ClassC(){
public void print(){
System.out.println("ClassB method implementation");
}
};
ref.print();
}
}
Result Will be "ClassB method implementation"