[Logo]
Forums Register Login
static methods and overrides
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.
[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.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards


This thread has been viewed 561 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jun 20, 2018 13:24:47.