Hi,
Murtuza,
It doesn't make perfect sense when there is a method in the sub class with the same name i.e. call(). The method has been invoked with the sub class instance only. That method in the sub class was also present at the compile time, then why the JVM thought it that way. It should have checked in the sub class too as the object that has invoked the f()in that of C Class.
Since Khalid wrote that answer, one can easily take it as it is (which is right as they are good at Java). The behavior of JVM surprises us (or me whatever) a lot of time. But still, I am not satisfied with that explanation.....
I guess I clearly wrote the sentence in the Khalid Book, anyway here it is again (for you) the whole sentence:
"The overridden method in the superclass is not inherited by the sub class....." as on page 233 line no 4.
Here's another one for your entertainment pleasure (got to say that as it is amusing).
At page 254 Under sub topic "Extending Interface" (in the context of interface)
Overridden methods are not inherited. What's that??? If they are not inherited then how come we override it to achieve
polymorphism!!!
Private method are private they cannot be inherited and hence no overriding is possible so no point quoting it in the book (it is obvious).
I read each and every book properly. Had I not been reading it properly I would have never pointed out those sentences.
Anyways, you seem to be a big fan of author Khalid(might be some other book), I guess my sentence hurt you. Sorry if that's the case but I still say it is making me sick.... can't help much as that's the only book I am having for the preparation. I wish I had started from K&B book.