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
enthuware.ocajp.i.v8.2.1410
Moderators: Site Manager, fjwalraven
-
- Posts: 1
- Joined: Sat May 21, 2016 2:13 pm
- Contact:
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: enthuware.ocajp.i.v8.2.1410
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.
thank you for your feedback!
Paul.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 10 guests