We are independent & ad-supported. We may earn a commission for purchases made through our links.
Advertiser Disclosure
Our website is an independent, advertising-supported platform. We provide our content free of charge to our readers, and to keep it that way, we rely on revenue generated through advertisements and affiliate partnerships. This means that when you click on certain links on our site and make a purchase, we may earn a commission. Learn more.
How We Make Money
We sustain our operations through affiliate commissions and advertising. If you click on an affiliate link and make a purchase, we may receive a commission from the merchant at no additional cost to you. We also display advertisements on our website, which help generate revenue to support our work and keep our content free for readers. Our editorial team operates independently of our advertising and affiliate partnerships to ensure that our content remains unbiased and focused on providing you with the best information and recommendations based on thorough research and honest evaluations. To remain transparent, we’ve provided a list of our current affiliate partners here.
Technology

Our Promise to you

Founded in 2002, our company has been a trusted resource for readers seeking informative and engaging content. Our dedication to quality remains unwavering—and will never change. We follow a strict editorial policy, ensuring that our content is authored by highly qualified professionals and edited by subject matter experts. This guarantees that everything we publish is objective, accurate, and trustworthy.

Over the years, we've refined our approach to cover a wide range of topics, providing readers with reliable and practical advice to enhance their knowledge and skills. That's why millions of readers turn to us each year. Join us in celebrating the joy of learning, guided by standards you can trust.

What Is an Abstract Method?

By Jean Marie Asta
Updated: Jan 27, 2024
Views: 8,016
Share

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.

Share
WiseGeek is dedicated to providing accurate and trustworthy information. We carefully select reputable sources and employ a rigorous fact-checking process to maintain the highest standards. To learn more about our commitment to accuracy, read our editorial process.

Editors' Picks

Discussion Comments
Share
https://www.wise-geek.com/what-is-an-abstract-method.htm
Copy this link
WiseGeek, in your inbox

Our latest articles, guides, and more, delivered daily.

WiseGeek, in your inbox

Our latest articles, guides, and more, delivered daily.