10.3 The protected Access Modifier
We have seen that the subclass does not inherit constructors or private members of the superclass. However, the superclass constructors are still available to be called from the subclass and the private fields of the superclass are implemented as fields of the subclass.
Although private fields preserve encapsulation, there is additional processing overhead involved with calling methods. Whenever a method is called, the JVM saves the return address and makes copies of the arguments. Then when a value-returning method completes, the JVM makes a copy of the return value available to the caller. The protected access modifier was designed to avoid this processing overhead and to facilitate coding by allowing the ...
Get Java Illuminated, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.