Page 1 of 1

enthuware.ocajp.i.v8.2.1410

Posted: Sat May 21, 2016 2:17 pm
by edgannon
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

Re: enthuware.ocajp.i.v8.2.1410

Posted: Sun May 22, 2016 8:54 pm
by admin
You are right. I do not think protected should be a correct answer. Only private should be correct. Fixed.

thank you for your feedback!
Paul.