A method is a function that belongs to a class. It defines what an object can do.
Where a plain function stands on its own, a method is always attached to a class. When you call a method, you call it on a specific object — and the method can work with that object’s data.
Defining a Method#
A method is defined inside the class body. It has a name, a return type, and a body.