As the previous optimization attempt went well, where I studied for chapter 6, I would like to do the same for chapter 4. In this attempt, I will get specific parts of chapter 4, that will be useful for chapter 5, and once I understand the concepts, I will switch to chapter 5.
Applying Access Modifiers
You already saw that there are four access modifiers: public, private, protected, and
default access. We are going to discuss them in order from most restrictive to least restrictive:
■ private: Only accessible within the same class
■ default (package private) access: private and other classes in the same package
■ protected: default access and child classes
■ public: protected and classes in the other packages
Private Access
Private access is easy. Only code in the same class can call private methods or access
private fields.