Category: 

What is an Abstract Class?

Article Details
  • Written By: Kari Wolfe
  • Edited By: Angela B.
  • Last Modified Date: 15 September 2016
  • Copyright Protected:
    2003-2016
    Conjecture Corporation
  • Print this Article
Free Widgets for your Site/Blog
The atmosphere of Jupiter's moon Io collapses every time it is eclipsed by the planet.   more...

September 29 ,  2008 :  The Dow Jones Industrial Average experienced its largest one-day drop in history.  more...

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.

Ad

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.

Ad

You might also Like

Recommended

Discuss this Article

Post your comments

exception 'Exception' with message 'error writing captcha: Duplicate entry '2147483647' for key 'PRIMARY'' in /ssd/www/wisegeek/public_html/_core/classes/public/Captcha.php:44
Stack trace:
#0 /ssd/www/wisegeek/public_html/_core/controls/public/ControlDiscussionPostBox.php(324): Captcha->createCaptcha()
#1 /ssd/www/wisegeek/public_html/framework/classes/Control.php(104): ControlDiscussionPostBox->preRender(false)
#2 /ssd/www/wisegeek/public_html/framework/classes/Control.php(149): Control->render()
#3 /ssd/www/wisegeek/public_html/tpl/default-nocustom-lu/pages/public/article/article.htm(526): Control->__toString()
#4 /ssd/www/wisegeek/public_html/framework/classes/Control.php(300): require('/ssd/www/wisege...')
#5 /ssd/www/wisegeek/public_html/framework/classes/Control.php(309): Control->requireTpl('pages/public/ar...', Object(PageArticleCom), true)
#6 /ssd/www/wisegeek/public_html/framework/classes/Control.php(131): Control->renderTpl('pages/public/ar...', Object(PageArticleCom))
#7 /ssd/www/wisegeek/public_html/framework/classes/FormDataControl.php(87): Control->renderTemplate()
#8 /ssd/www/wisegeek/public_html/framework/classes/Control.php(109): FormDataControl->renderTemplate()
#9 /ssd/www/wisegeek/public_html/framework/classes/ScriptPage.php(50): Control->render(false)
#10 /ssd/www/wisegeek/public_html/framework/classes/Control.php(149): ScriptPage->render()
#11 /ssd/www/wisegeek/public_html/framework/classes/Page.php(97): Control->__toString()
#12 /ssd/www/wisegeek/public_html/_core/classes/public/PublicFrontController.php(443): Page->processRequest()
#13 /ssd/www/wisegeek/public_html/_core/classes/public/PublicFrontController.php(7): PublicFrontController->renderPage()
#14 /ssd/www/wisegeek/public_html/index.php(11): PublicFrontController::run()
#15 {main}