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 Class?

By Kari Wolfe
Updated: May 17, 2024
Views: 6,252
Share

In object-oriented programming, an abstract class provides a base class that can be used to provide other classes with partial implementation and interface. They are incomplete by themselves and used in inheritance situations in many programming languages such as Java, C++ and C#. Their usage as a base class means they are often referred to as an abstract base class (ABC).

An integral part of object-oriented programming, data abstraction removes the unnecessary details of an object. Essentially, it boils the object down to its main identifying characteristics. These basic characteristics provide a blueprint that can be used to create other objects with the same properties, only differing in the details.

This blueprint is defined as a class. Classes are used to encapsulate the code, making it easier for the programmer, because he can reference specific common routines instead of writing the routines over and over. Programmers create child objects from classes, and these objects inherit the functions and methods within the parent class.

The purpose of an abstract class is to be the framework upon which other classes are built. Objects cannot be created directly from an abstract class, only from the subclasses belonging to the abstract class. For an object to inherit from an abstract class, a subclass has to be created. Objects of a created subclass of an abstract class inherit properties of that abstract class.

Every class models a concept, and abstract classes tend to model more abstract concepts using abstract methods. Abstract methods are subroutines inside an abstract class that contain no implementation. These subroutines are used as placeholders to be overwritten by a subclass or an object designed based on the class that contains the abstract method itself.

There are different methods of creating an abstract class. For example, in C++, an abstract class is created by developing a class with at least one abstract method or pure virtual function. Java uses a keyword, “abstract,” to denote an abstract class. They are not, however, defined in programming languages that do not support the idea of inheritance.

Inheritance is the process of creating new objects from classes where the new objects can use the functions and methods defined within their parent classes without the need to restate the program. This is why an abstract class is useful. Child classes and child objects of those subclasses inherit properties from the parent abstract class. Abstract classes are considered superclasses and are at the top of the class structure hierarchy, so they have no point in a language that does not support inheritance.

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.wisegeek.net/what-is-an-abstract-class.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.