Difference between revisions of "Abstract Class"

esse quam videri
Jump to: navigation, search
(External Links)
(Definition)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  
 
=Definition=
 
=Definition=
 +
An abstract class is a class that cannot be instantiated.
 +
 +
It's a generic class (or type of object) used as a basis for creating specific objects that conform to its protocol, or the set of operations it supports. Abstract classes are not instantiated directly.
 +
 +
An abstract class is a base class that has very basic requirements of what a class should look like. It isn’t possible for child classes to inherit the methods of the base class.
 +
 +
=What this means=
 +
Think about an animal, maybe you're thinking about a dog or a cat. Both animals belong to the class "Mammal". Now, imagine that a pet owner wants to call their pet. Would they say dog (but with a name of course) or mammal? A mammal is a broad definition, hence calling it anywhere isn't specific enough for humans, let alone computers. So, if we were to call an abstract class in the main method, this wouldn't be possible since it's too broad of a subject.
  
 
=Relevance=
 
=Relevance=
 +
*[[Class]]
 +
*[[Instance]]
 +
*[[Inheritance]]
  
 
=Explanation=
 
=Explanation=
 +
Abstract classes are commonly used for inheritance since they cannot be instantiated themselves while a child or descendant does become an instance.
  
 +
===If the Animal Kingdom were an abstract class===
  
 +
[[File:Abstract.png| 650px]]
  
=Resources=
 
 
== See also ==
 
== See also ==
  
Line 15: Line 28:
 
* [[Object Oriented Programming]]
 
* [[Object Oriented Programming]]
  
==Notes==
 
  
  
==External Links==
 
  
  

Latest revision as of 23:56, 9 August 2019

Definition

An abstract class is a class that cannot be instantiated.

It's a generic class (or type of object) used as a basis for creating specific objects that conform to its protocol, or the set of operations it supports. Abstract classes are not instantiated directly.

An abstract class is a base class that has very basic requirements of what a class should look like. It isn’t possible for child classes to inherit the methods of the base class.

What this means

Think about an animal, maybe you're thinking about a dog or a cat. Both animals belong to the class "Mammal". Now, imagine that a pet owner wants to call their pet. Would they say dog (but with a name of course) or mammal? A mammal is a broad definition, hence calling it anywhere isn't specific enough for humans, let alone computers. So, if we were to call an abstract class in the main method, this wouldn't be possible since it's too broad of a subject.

Relevance

Explanation

Abstract classes are commonly used for inheritance since they cannot be instantiated themselves while a child or descendant does become an instance.

If the Animal Kingdom were an abstract class

Abstract.png

See also