Hello all,
I have an easy question around method access control I wanted to ask to make sure I'm understanding the concept.
Here would be the scenario.
A Parent Class is created and there is a Parent method in that class.
several child classes will inherit, using extends, from the parent class to use the Parent method.
To ensure the Parent method is available to any Child Class I would set the method modifier in the Parent Method to Protected.
This will allow the Child Class to see the Parent Method.
Alternatively if I set the Parent method to the default Private modifier, the Parent method would not be seen from the child class.
Finally if I set the Parent Method to the Public modifier the Parent method becomes available to any other class which ultimately can lead to bad coding practices and makes things more difficult for debugging.
Is that correct?
Please let me know if it isn't or feel free to add additional comments.