Originally posted by Angela Ann:
Encapsulation has nothing to do with the access modifiers. This is a common misconception with people learning OOP. Encapsulation means that your data and the methods that operate on that data should be bundled together. The use of getters/setters in a program is information hiding. It is good practice, but doesn't create encapsulation.
Originally posted by dipak chand:
As for u r question goes best acess modifier for encapsulation
is protected because allow the subclassed classes access to the member, and members in the package.
deepak
You can't have everything. Where would you put it?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|