Access modifiers
Suppose d is an instance of Employee, where class Employee is declared as:
{<access modifier> int x;
If the <access modifier> is:
- public, then field d.x can be referenced anywhere that d can be referenced.
- private, then field d.x can be referenced anywhere within class Employee that d can be referenced
- protected, then field d.x can be referenced anywhere within the package in which Employee is declared (packages are discussed later).