There are 3 access specifiers in Java public, private and protected. A public member can be accessed by any part of code in the program; however a private member can be accessed by only the class where it is defined. The default access specifier is public for any class. However, it is public for its package and not for other packages. A package is simply a group of classes. Java uses another access specifier protected whenever it has to use inheritance.
public int y;
private int z;