jQuery in Action, 2nd edition*
The moose likes Java in General and the fly likes can we inherit a final method from the subclass? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "can we inherit a final method from the subclass?" Watch "can we inherit a final method from the subclass?" New topic
Author

can we inherit a final method from the subclass?

senthil sen
Ranch Hand

Joined: Oct 10, 2002
Posts: 184
can we inherit a final method from the subclass?
Say i have a mehtod in Class A with is final.
I have a class B which extends Class A.will the final method in the class A be inherited in class B.??
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Sure. You just can't change a final method or field.
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2853
    
  11

Unless of course the method is private final. (Or package private, i.e., not public, protected, or private, and the superclass and subclass are in different packages.) Then it can't be called by the subclass. Of course, that's true for any method, final or not.
 
GeeCON Prague 2014
 
subject: can we inherit a final method from the subclass?