Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

"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
 
What's wrong? Where are you going? Stop! Read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic