• 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

Accessing Super.Super from derived class

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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().
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic