You control the access to a class using access modifiers
which define different levels of access for class members.
For example, you might want the member variables for a class to only be accessible to derived classes.
You must declare an access modifier before the type of a member variable, the return type of a method, or the definition of a class.
Java supports four different access modifiers: public, protected, default, private. Some of these modifiers apply to classes, some to class members, and some to both:
This Slideshow shows how the different access modifiers apply to a group of classes.
The frames demonstrate accessibility with respect to the Dog class: