The MasterExam software with Bert & Kathy's book has an explanation for a question that says that the "access modifier does not affect encapsulation". My copy of the software does not allow me to go back and find that question after time has expired, and my frantic in-exam notes with a question mark about this topic weren't extensive enough for me to know exactly what the situation was, but I suppose I can ask about when you can say there is good encapsulation in general since I'm a little hazy on this. I understand that public setters/getters with private members makes for tight encapsulation, and that an example of bad (or loose?) encapsulation would be public instance member variables, but in case the exam tests me on this, I'm trying to figure out how to accurately describe the level of encapsulation when member vars and methods have other combinations with protected/default and such. Any concise/memorable explanation would be greatly appreciated!
The purpose of encapsulation is to keep inner workings of the component invisible (read private) to the outside world while providing access to the properties using acessor methods (read setters and getters). So, it is imperative that the members field is private and the accessor methods are public. In this sense, access modifier does affect encapsulation. If you have a public member variable with private accessor methods( ), then it is not encapsulation.
Yeah, but I know the question had something to do with how you describe the level of encapsulation when you're dealing with protected/default access, and I understand what level of access protected/default gives, but I'm just wondering if they're going to throw a tricky question at me about how you describe the encapsulation (like, does a protected member var or method show good encapsulation?).