This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

method overriding

 
Komal Amaresh
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir,

It is mentioned that a subclass method can have the same signature and the name of a private method decalared in the super class. The primary purpose of declaring a private method is lost is so as the basic aim of creating a private method is to implement encapsulation. Besides as the main is declared in the child class, what is the use of creating a private method in the super class. Please explain.

Thanks in advance.

with regards,
Komal Amaresh
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Same as in the superclass. It provides a method for use only inside that class. If you use the superclass properly, by reading its javadoc comments rather than its code, you should never even know you are "overriding" a private method.

I am not sure, but I don't think it's really overriding or hiding, because the subclass is not "aware" of a private superclass method. It is more like writing a new method. Anybody wish to correct me on that point?
 
Sagar Rohankar
Ranch Hand
Posts: 2905
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:

I am not sure, but I don't think it's really overriding or hiding, because the subclass is not "aware" of a private superclass method. It is more like writing a new method. Anybody wish to correct me on that point?


I agreed . private method can't overridden, coz sub class never inherit them and about hiding, they are not static.
 
Rob Spoor
Sheriff
Pie
Posts: 20388
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sagar Rohankar wrote:coz

Please Use Real Words.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic