Abstract Class

esse quam videri
Jump to: navigation, search


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.



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


See also