In object oriented programming, subroutines called “methods” are used to perform functions in a program. These methods consist of programming statements that perform an action, set up input parameters to customize actions, and can return or output a value of some kind of object or class. Methods are the actions performed in a program from a certain class or within an object, and are used to access and manipulate data stored within an object. There are many different methods and each has a particular use. A specific type that is performed from an abstract super class and inherited by subclasses is known as an abstract method.
Generally, the abstract method performs little or no implementation within its abstract super class. Codes contained within this kind of method are considered dummy codes and are not implemented themselves. This does not mean the specific abstract method in a particular abstract class does not get used. Rather, the abstract method acts as a model or placeholder for subclasses to finish the implementation of the method.
Super classes may contain multiple subclasses, and all subclasses of a super class have certain similar states and behaviors. Abstract classes, therefore, are a type of virtual class that exhibits virtual inheritance. This means that any subclass derived from a super class inherits the restrictions of the super class from which it is derived. Therefore, methods in subclasses are derived from abstract methods of super classes. When programming and using abstract methods, the programmer must declare the class abstract rather than virtual.
For example, a super class of “Graphic Objects” contains the subclasses “Circle,” “Square,” etc. As such, all Circles and Squares have the same states — orientation, position, fill color, line color — and behaviors — moveTo, resize, rotate, draw — as “Graphic Objects.” All subclasses in this super class have the same qualities, but they are implemented in different ways. The abstract method of the super class provides the groundwork without implementation, and the subclasses perform the actual implementation using the same methods. Even though each subclass uses the same method as the abstract class, they uniquely define the way in which the method will be carried out.
Using an abstract method allows for generalization at the top level, or super class, and specification at the lower levels, or subclasses. This hierarchy minimizes the amount of method programming to each specific subclass. Using these methods also allows for idempotency of subclasses, meaning that if a method is implemented over and over, the result is the same every time.