enthuware.ocajp.i.v8.2.1410
Posted: Sat May 21, 2016 2:17 pm
Hello,
I have a question about this answer explanation:
protected is also a valid way to encapsulate a field because only a subclass is able to inherit and access the field.
Protected allows subclasses and packages access, so is less restrictive than default access. The next explanation says:
No access modifer to age means it has default access i.e. all the members of the package can access it. This breaks encapsulation.
If that is true, then protected would also break encapsulation, correct?
Thank you,
Ed Gannon
I have a question about this answer explanation:
protected is also a valid way to encapsulate a field because only a subclass is able to inherit and access the field.
Protected allows subclasses and packages access, so is less restrictive than default access. The next explanation says:
No access modifer to age means it has default access i.e. all the members of the package can access it. This breaks encapsulation.
If that is true, then protected would also break encapsulation, correct?
Thank you,
Ed Gannon