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

Accessing Super.Super from derived class

 
Arvind Varma
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why cannot we call super.super.someMethod()
in class A that extends B that in turn extends C. all of them implement
someMethod().
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because it would break encapsulation: A shouldn't need to know that B extends C, as this is an implementation detail of B. It would make your design much more fragile if A would know.
Why do you want to? We probably could find a more appropriate solution...
 
Arvind Varma
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats true...I understand its more of a design decision than an implementation Issue. So basically in order to support encapsulation java doesn't allow to access C from A(i tried doing that and got an error thrown). Correct me if i'm wrong
It is more out of curiosity that i wanted to know why is it like that.
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic