Can anybody please comment on this code...it works fine and displays the output as "In Main2's Static" i do not understand why...
Has this anything to do with inheritance please advise...
Thanks Irina for your reply...
But as far as i know that the static methods are not inherited as they are a part of the class but not a part of the any instance ? So don'nt you think it violates the definition of Static ?
Originally posted by Vaibhav Wahee:
...as far as i know that the static methods are not inherited as they are a part of the class but not a part of the any instance ? So don'nt you think it violates the definition of Static ?
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Thanks marc for your prompt reply. But i did'nt get your point. How can a static method which is specific to Class Main2 be called upon a reference of it's subclass Main. Does this mean that static methods are indeed inherited ?
Can anyone please comment on this ?
Still waiting for an opinion....
Thanks for your reply and clarification. I never knew that a static is not barred from inheritance ...But the K&B books fails to mention this fact.....
I mean i was not able to extract this info from their SCJP 1.5 book
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
This example above clearly states that a static method is indeed inherited but not overridden....but still i've found this to be true that many persons fail to recognise this fact that static methods are also inherited
A class C inherits from its direct superclass and direct superinterfaces all non-private methods (whether abstract or not) of the superclass and superinterfaces that are public, protected or declared with default access in the same package as C and are neither overridden (�8.4.8.1) nor hidden (�8.4.8.2) by a declaration in the class.
A hidden method can be accessed by using a qualified name or by using a method invocation expression (�15.12) that contains the keyword super or a cast to a superclass type.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Manish
Thanks and regards,<br />SanKet Modi
Originally posted by sridhar row:
if static methods cant be overridden why does this give a compilation error.
Originally posted by Vaibhav Wahee:
This code compiles fine...which again proves beyond doubt that static methods are indeed inherited.
A class C inherits from its direct superclass and direct superinterfaces all non-private methods (whether abstract or not) of the superclass and superinterfaces that are public, protected or declared with default access in the same package as C and are neither overridden (�8.4.8.1) nor hidden (�8.4.8.2) by a declaration in the class.
For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|