• 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

"private" methods are implicitly "final"?

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I apoligize for the previous posting of my question. As I read from "Think in Java", Bruce Eckel, private methods are implicitly final, meaning that the method cannot be overriden. I ran the following code using Metrowerks CodeWarrior, and it prints "Sub".



 
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Private methods are not inherited by subclasses, so the method in Sub is not overriding the private method in Super. Please refer to section 8.4.6 of the Java Language Specification. Section 8.4.3.3 mentions of the JLS mentions that private methods are implicitly final.
One way to see this directly is to give the Super class a main method that does this:
Super s = new Sub();
s.method();
and see what prints out when you run that class.
John
[This message has been edited by John Wetherbie (edited January 15, 2001).]
 
Son Le
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John,
Thanks for replying. I had found in another book that we can re-define a private method, and it's not related to overriding.
Tho
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic