As we all know that we can’t override final method, but if we try to do so, then java gives compiler error. But actually override is all going on Runtime ? Why does so ?
I tried to code it, and it gave me compiler error
public class Test{
public final void meth(){
System.out.println("Method from Test");
}
}
public class Main extends Test{
public final void meth(){
System.out.println("Method from Main");
}
public static void main(String[] args) {
System.out.println("Hello World");
}
}
New contributor
Niraj Amrutkar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.