"Make the fields or methods protected if they are intended for the extenders of the class but not the users of the class."
Don't understand who suppose to be "the users of the class" in this context?
It makes sence to me only if "users" are instances of the class with protected members, inside class from different package.
Basically, as long as you know how to access the child of the parent's class, protected can be abused and let you access that parent's variable directly and even changing it. I did not use protected in my assignments at all because I found this exploit
For example, Shape is the parent of Triangle and in the Shape class there is a variable called size, I can call this in my main:
Triangle t1 = new Triangle();
t1.size = 100;
The "users" are other classes that use objects of this class or its children.
Originally Posted by diamonddragon