This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static methods

 
sonali rao
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can static methods be orver ridden?
 
Sindhur Sat
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NO
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope, but they can be hidden. Static methods are not polymorphic. Consider the following:

In this scenario, instances of C can accesses any of the static methods by qualifying the call with the class:

But now C can no longer access the instance methods of A since a super call only applies to B. In the above example, if the class qualifier is removed, then the hidden static method defined in the subclass will be called or the most immediate super class that hides the static method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic