• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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..
 
Did you ever grow anything in the garden of your mind? - Fred Rogers. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic