BEE MBA PMP SCJP-6
BEE MBA PMP SCJP-6
"If the facts don't fit the theory, get new facts" --Albert Einstein
Mohnish Khiani wrote:
It's output is :
Static func1 of hobbit
Static func1 of hobbit_exp
Static func1 of hobbit
I understand that this is not dynamic polymorphism because which static method is to be invoked depends on the reference type rather than the actual object type....but then what is this called when I can redifine the static method in my subclass....do static methods get inherted?
abhilash pallerlamudi wrote:static methods does not participate in inheritance.
Mike Simmons wrote:
abhilash pallerlamudi wrote:static methods does not participate in inheritance.
I disagree with this statement. Where did this idea come from? Do you have a link? If you look at, for example, the Java Tutorial on Inheritance, they don't say anything about static members not participating in inheritance. I think perhaps you mean to say that static methods do not participate in overriding. This is correct. But overriding is not the same as inheritance. It's just a different way that inheritance works for static members.
Mike Simmons wrote:So, no link? No idea where this information comes from? The way you use the term "inheritance" does not appear to have anything to do with how it's used in the Java Tutorial or Java Language Specification.
Members are either declared in the type, or inherited because they are accessible members of a superclass or superinterface which are neither private nor hidden nor overridden(§8.4.8).
The members of a class type are all of the following:
Members inherited from its direct superclass (§8.1.4), if it has one (the class Object has no direct superclass)
Members inherited from any direct superinterfaces (§8.1.5)
Members declared in the body of the class (§8.1.6)
See if you can find another link; that discussion is really difficult to understand. We have an FAQ, for example.abhilash pallerlamudi wrote: . . . are statics inherited?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |