A class member which is either data member or member function can be declared with any of the following access mode specifiers:
- private - A private member is accessible only within the class, in which it is declared that is member functions within that class, can only access them.
- public - A public member can be accessed even outside the class in which it is declared.
- protected - A protected member can be accessed by the class in which it is declared and by its derived classes.
- default or 'package-private' - It is the additional access mode specifier to the above three access modes as it is introduced in Java. Java is a true object-oriented programming language. So everything in Java is implemented as an object. When a variable is declared without any access specifier it assumes that as default access mode which means it can be accessed by all the classes defined within that package. But the classes outside the package cannot access it. This means a default member is public to all the classes within the same package, in which it is defined. Hence the name 'package-private' mode.