Using Access Modifiers
As mentioned at the beginning of the chapter, encapsulation, the capability to hide data and methods to stop them from cluttering up the rest of your code, is one of the biggest advantages of OOP. Encapsulating data and methods not only ensures that they don't clutter up the rest of your code, it also ensures that the rest of your code doesn't interfere with them. You can use access modifiers to set the allowed access to not only classes, but also to all members of those classes. Here are the available access modifiers:
The public keyword gives a type or type member public access, the most permissive access level. There are no restrictions on accessing public members.
The protected keyword gives a type or type member protected ...