Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static methods and overrides

 
kambiz shahri
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not possible to override an inherited static method...so the Java cert books says. You can only "redefine the method" in a subclass of the superclass that defined the static method.

However when in eclipse i try to "redefine" the inherited static method, it will complain if try to narrow the access modifier.

The certification book is NOT any clearer on the subject.

thanks for the answers in advance.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[KS]: However when in eclipse i try to "redefine" the inherited static method, it will complain if try to narrow the access modifier.

Yes, that's because the rules for method hiding (what your book calls "redefining") are similar to the rules for overriding. That doesn't mean that static methods can be overridden - it just means that some of the behavior is similar.

I recommend reading Overriding vs. Hiding for more discussion.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic