I have programmed in Java for some time and I just realized that the protected
access modifier allows members to be accessed also in the same package. So here is the situation and the question:
I have a class having a protected
method, and a test class using Mockito to stub that method. The two classes are located in different folders (a src and a test), but their package names are the same! The funny thing is, I can call the protected method in the test class! I would like to know how it is possible? Because their package names are the same? In this case the protected
modifier does allow a very wide access!