• Post Reply Bookmark Topic Watch Topic
  • New Topic

Static Method  RSS feed

 
Bubai Basu
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any class inherit a static method of its super class?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As static methods are supposed to be called in a static context, I don't see where inheritance is related. A protected static method can be called by a subclass. If you have an example which comes to mind, could you please post it ?
 
Vyas
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
strange question, nice answer
 
Kaydell Leavitt
Ranch Hand
Posts: 690
Eclipse IDE Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can any class inherit a static method of its super class?


Yes, every class inherits the static methods of its anscestor classes unless a subclass has a method with a signature that is the same as a static method in an ascestor class. in this case, the method in the subclass shadows the method in the anscestor class. The word "shadows" means that the method in the subclass "casts its shadow and hides the method in the anscestor class".

Kaydell
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!