Hi All, I have come to know that when a subclass outside the package of the superclass acess a protected meber of the super class it becomes private to the sub class. That is no other class in the same package as the sub class can acess it. But will thai apply to a sub class of that particular sub class as well?
"Failures are the pillars of success" - but that doesn't mean you go on building pillars
That subclass wont inherit the member because it is private
I wrote the following code, it shows that the protected member of a super class is inherited by the subclass of the subclass in different packages.
The output I got is as below:
In C: protected int a = 10 In D: protected int a = 10 In D: protected int a = 10 In E: protected int a = 10 In C: protected int a = 10 In F: protected int a = 10
The above output certainly says that the protected member is inherited by all subclasses whether present in same package or not;
So I am interested to know, where does the protected member access change to private? Except being unble to access the protected member using an instance of the class in a different package, the access does not seem to be changing to private. (i.e a.a, b.a, etc. not allowed)
Nothing? Or something? Like this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database