• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Overriding final methods

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought final methods cannot be overridden. But the below code compiles just fine. Can somebody explain.

[ Added UBB [CODE] tags to add whitespace, improve readability ]
[ May 14, 2002: Message edited by: Jessica Sant ]
[ May 14, 2002: Message edited by: Sagar Salapaka ]
 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the f() method in WF is private which is accisible within only WF class. If you declare the f() in WF to be public or protected, you will get compile time error what you are expecting. The f() method declared in derived class is consided a brand new method which is no connection with the superclass. Guys, am i correct?
 
Sagar Salapaka
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Thiru. It makes sense. Learnt something new today. Have a nice day!
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Thiru Thangavelu:
I think the f() method in WF is private which is accisible within only WF class...Guys, am i correct?


Yup, that's right. Private methods are not inherited. In fact, they're not even visible from outside the class, so you can't possible override or hide them.
Corey
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, private methods are implicitly final, so including the final modifier is redundant.
 
reply
    Bookmark Topic Watch Topic
  • New Topic