• 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

Inner class in abstract class

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have implemented an Protected inner class inside an abstract class, so all the first level of concrete classes extending the abstract class will have the visibility to the inner class right? (since it is protected). But second level of classes also can see the inner class. Am i wrong or i understood something wrong. Please clarify. Code chunk,

 
Bartender
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can declare inner class as private or protected, right?
private innser class can be accessed only from the enclosing class, and protected inner class can be accessed from any inheriting classes of the encapsulating class.

It's almost as like talking about private and protected members of the class in terms of inheritance.
 
Ranch Hand
Posts: 375
1
Python Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Arunan Ramanathan wrote:I have implemented an Protected inner class inside an abstract class, so all the first level of concrete classes extending the abstract class will have the visibility to the inner class right? (since it is protected). But second level of classes also can see the inner class. Am i wrong or i understood something wrong. Please clarify. Code chunk,



Well, there are two cases...
One, where you redefine the method(or class in this case) in the derived class (1st level derivation), with decreased visibility (private in this case)..
Second, where you don't redefine the method(or class), or redefine it with the same visibility but different functionality...

Now you can see, what happens to the visibility of the method(or class) in the 2nd level derivation in both the cases...
Not-Visible in 1st case, AND Visible in 2nd case..
 
reply
    Bookmark Topic Watch Topic
  • New Topic