In programming, a method is a set of instructions that perform a specific task and can be called (invoked) at any point in a program simply by utilizing the methods name. In object-oriented programming (OOP), a method is a programmed procedure that is defined as part of a class and is available to any object instantiated from that class. A method is associated with an object and defines the behavior of the objects that are created from the class.
Methods are similar to functions, but methods are also classified according to their purpose in the class design. In classes, variables are called attributes, so methods often operate on attributes. There are three main types of methods: interface methods, constructor methods, and implementation methods.
The use of methods allows for the repetition of sections of code without retyping the code, and methods can be saved and utilized again and again in newly developed programs. The ability to create classes and methods and then access those methods through instantiated objects is one of the most powerful capabilities in OOP languages.