Skip to main content

All Questions

-2 votes
1 answer
504 views

Protected variable not accessible within child class in Java

I have the following structure - App.java - package JohnParcellJavaBasics.AccessModifierDemo; import JohnParcellJavaBasics.AccessModifierDemo.*; public class App { public static void main(String[]...
Payel Senapati's user avatar
0 votes
1 answer
62 views

Package-private member visibility in complex inheritance / package combinations - Qiuck General Rule to verify visibility

If Base and Derived classes are in different packages then package-private member from Base shall not be inherited and thus it shall be absent in Derived, that is such member shall be inaccessible ...
Code Complete's user avatar
0 votes
1 answer
761 views

Why is a protected variable visible at class level? [duplicate]

A protected variable is access to any class within a package and only to a subclass that extends the base class outside the package. Why did Java implemented this in this was i.e default within ...
user892871's user avatar
  • 1,025
1 vote
0 answers
32 views

Why cannot I see third party protected members of parent? [duplicate]

I noticed strange behaviour of access modifier package protected_test.pack1; public class Source { protected int protectedInt= 1; } package protected_test.pack2; import protected_test....
gstackoverflow's user avatar
2 votes
1 answer
268 views

php inheritance with protected array property is giving me a serious headache

So I decided to make some classes in PHP so I can dynamically construct a menu bar using <ul>, <li> and <a> tags. Reason why is because I want to reuse this across projects. First the Blob ...
Jif's user avatar
  • 843
2 votes
3 answers
836 views

Overrided method visibility in Java

Assume that we have a package "p1": package p1; public class A { protected void method() { } } ... and we also have a package "p2": package p2; import p1.A; public class B extends A { } ...
Ilya Gubarev's user avatar
6 votes
4 answers
3k views

Policy inheritance and inaccessible protected members

It seems that a protected member from a template policy class is inaccessible, even with a class hierarchy which seems correct. For instance, with the following code snippet : #include <iostream&...
benlaug's user avatar
  • 2,741
3 votes
5 answers
7k views

Java Protected Access Not Working

In java, there's three levels of access: Public - Open to the world Private - Open only to the class Protected - Open only to the class and its subclasses (inheritance). So why does the java ...
Anton's user avatar
  • 1,427