This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
But according to the book (which is indeed true, as this is what happens). The following action sets all the properties.
From what i have learnt w.r.t to JavaPolymorphism is that a reference variable can invoke (at runtime, through dynamic dispatch) only the methods that it knows about. This means (assume B is subclass of A)
a can invoke methods that are overridden.
a cannot invoke:
methods that are only in B // This is what seems to happen here
methods that are only in A //off course, because the actual object instantiated is of type B.
How then, is personBean able to set empId which is not overridden and which solely belongs to the subclass. Please help. It is not a very encouraging feeling to have when you are thinking about giving SCJP and find your Inheritance fundamentals challenged. Thanks.