nothing strange here.. polymorphic rule.. RTTI... type of the object is Child... therefore the method from child is invoked. btw... preferably don't use this style of coding unless the invoked methods are private or final. It could cost a hapless maintenance chap a lot of sleepless nights.
Objects always know 'who they are ' on the basis of instanceof operator. When an object is created the instances of all its super classes are also created.at runtime it is decided which implementation is called.(except for static methods which are resolved at compile time.
That which doesn't kill us makes us stronger. I think a piece of pie wouldn't kill me. Tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps