
Getting ready
The term object usually refers to an entity that couples data and procedures that can be applied to this data. Neither data nor procedures are required, but one of them is—and, typically, both are—always present. The data is called object fields (or properties), while procedures are called methods. Field values describe the object's state. Methods describe the object's behavior. Every object has a type, which is defined by its class—the template used for the object's creation. An object is also said to be an instance of a class.
Encapsulation is the hiding of those fields and methods that should not be accessible by other objects.
Encapsulation is achieved by using the public, protected, or private Java keywords, called access modifiers, in the declaration of the fields and methods. There is also a default level of encapsulation when no access modifier is specified.