Difference between revisions of "Abstract Class"
esse quam videri
(→Explanation) |
(→If the Animal Kingdom were an abstract class) |
||
Line 14: | Line 14: | ||
Abstract classes are commonly used for inheritance since they cannot be instantiated themselves while a child or descendant does become an instance. | 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== | + | ===If the Animal Kingdom were an abstract class=== |
[[File:Abstract.png| 650px]] | [[File:Abstract.png| 650px]] |
Revision as of 15:23, 21 June 2019
Contents
Definition
An abstract class is a class that cannot be instantiated.
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.