Inheritance
Inheritance allows you to create a new class that contains fields and methods of an existing class, and add additional fields and methods. * The class you inherit from is often called the superclass, and the inheriting class is the subclass.
Practice Exercise¶
Superclass and subclass are commonly referred to as parent class and child class, respectively. You'll see both throughout this chapter.
When to Use Inheritance¶
Use inheritance when you want to avoid representing the same thing twice, in two separate classes. * A subclass is everything a superclass is, plus some. * Many subclasses can all inherit from a single superclass.
Practice Exercise¶
Inheritance is a fundamental principle of Object-Oriented Programming. It allows developers to quickly expand the functionality of their programs, building on what was done before.