Ikpefua Jacob-Obinyan wrote:Hello Fellow Ranchers,
I decided that we revisit the puzzle of static members inheritance, I have read lots of articles about this and there seems to be mixed opinion here and there. I believe that static members are inherited, to the best of my knowledge static methods CANNOT be 'polymorphically-overriden' rather they can be 'redefined', we are also aware that runtime-polymorphism does NOT apply to static members.
Further more the only members that obviously CANNOT be inherited are those marked with the private modifier, apart from that, the subclass has access to every other member in accordance with the other rules we know about 'default-package-level-protected-inheritance' and those I may NOT have mentioned herein. Please Ranchers your opinion is needed to resolve this doubt once and for all.
Boris Mechkov wrote:I think we are getting two things confused here. K&B book specifically mentions that static "methods" are not inherited. But since inheritance concerns only instance methods and not instance variables or static members variables. It is easy to conclude that that static variables are another form of a "variable" hence the access modifier will play a big role (if it is private we cannot use it in subclass, if it is public then we can and so on)...
it is even easier to understand if instead of inherited static members we use "accessed" static members.