class Ideone {
public static void main
(String[] args
) { ChildClass c = new ChildClass();
c.methodB();
}
}
class ParentClass {
public final void methodA() {
System.
out.
println("This is Parent A Method"); }
public void methodB() {
System.
out.
println("This is Parent B Method and I am Calling Method A"); methodA();
}
}
class ChildClass extends ParentClass {
@Override
public void methodB() {
System.
out.
println("This is Child B Method and I am Calling Parents Method B"); super.methodB();
}
}
Y2xhc3MgSWRlb25lIHsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB7CgkJQ2hpbGRDbGFzcyBjID0gbmV3IENoaWxkQ2xhc3MoKTsKCQljLm1ldGhvZEIoKTsKCX0KfQogCmNsYXNzIFBhcmVudENsYXNzIHsKICAgIHB1YmxpYyBmaW5hbCB2b2lkIG1ldGhvZEEoKSB7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJUaGlzIGlzIFBhcmVudCBBIE1ldGhvZCIpOwogICAgfQogCiAgICBwdWJsaWMgdm9pZCBtZXRob2RCKCkgewogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiVGhpcyBpcyBQYXJlbnQgQiBNZXRob2QgYW5kIEkgYW0gQ2FsbGluZyBNZXRob2QgQSIpOwogICAgICAgIG1ldGhvZEEoKTsKICAgIH0KfQogCmNsYXNzIENoaWxkQ2xhc3MgZXh0ZW5kcyBQYXJlbnRDbGFzcyB7CiAKICAgIEBPdmVycmlkZQogICAgcHVibGljIHZvaWQgbWV0aG9kQigpIHsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIlRoaXMgaXMgQ2hpbGQgQiBNZXRob2QgYW5kIEkgYW0gQ2FsbGluZyBQYXJlbnRzIE1ldGhvZCBCIik7CiAgICAgICAgc3VwZXIubWV0aG9kQigpOwogICAgfQp9