Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can we inherit a final method from the subclass?

 
senthil sen
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure. You just can't change a final method or field.
Michael Morris
 
Greg Charles
Sheriff
Posts: 2993
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic