We have next classes:
class Super {
void foo() {
System.out.println(\"Super\");
}
}
class Sub extends Super {
void foo() {
super
foo method override in sub class .super.foo() calling print super and then System.out.println("Sub"); shows Sub.
try this for inheritence
class Super {
Super()
{
System.out.println("1");
}
void foo() {
System.out.println("Super");
}
}
class Sub extends Super {
public Sub() {
// TODO Auto-generated constructor stub
System.out.println("2");
}
void foo() {
super.foo();
System.out.println("Sub");
}
}