public class A{
static public void method1(){
System.out.println("method a:1");
}
public void method2(){
System.out.println("method a:2");
}
}
public class B extends A{
static public void method1(){
System.out.println("method b:1");
}
public void method2(){
System.out.println("method b:2");
}
}
public class tmp {
public static void main (
String[] args){
A a = new B();
a.method1();
a.method2();
}
}
Output
method a:1
method b:2
Could anyone explain how we get the above output? Why don't we get the following output?
method b:1
method b:2
Thank you