says, a method is
[BOO91, p. 515]
The methods, defined in a class, indicate, what the instantiated objects are able to do.
An object's method is called by other objects of the system.
1. the object to whom the message is addressed
2. the name of the method to perform
3. any parameters needed by the method"
[CW96, "What are messages?"]
As mentioned before, we want to change our car's speed. To achieve this, the car's driver (also an object) has to call the "accelerate" method:
As the figure shows, the "accelerate" method was called with the parameter "80", which indicates the desired speed. By applying that method, the value of the variable "speed" had been changed. You don't change the state of an object (its variables) directly.
The fact that variables of an object are invisible to the outside is called encapsulation.