In a nutShell:Protected member not accessible through subclass object So i have a class named concrete in package say A1 then i have a class ConcreteSubClass (inheriting concrete) in package say A2 in the same file(as concreteSubclass) i have one last class Main. Here i am able to access the protected members of concerete in concretesubclass but not able to access them when i create a object of concreteSubclass in Main class in the same file Watch the video i shared for clarity
#Access modifiers
1 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @mental fossil! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
this is the access matrix
since Practice class is not a subclass of concrete it is not able to access protected method
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use/help ping.
Warning: abusing this will result in moderative actions taken against you.
But I am not accessing it directly I am accessing it through the object of concrete subclass isn't the object of concrete subclass supposed to have copies of all the fields in it including the inherited ones
All the fields are "copied", as you say, but do not change access modifiers. It means, even in Concrete subclass, protected fields remain protected and can't be accessed outside another subclass.
But say practice also extends Concrete now will i be able to access members of concrete but through object of concretesubclass in practice
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use/help ping.
Warning: abusing this will result in moderative actions taken against you.