Inheritance is one of the most important principles of object-oriented programming (OOP). It allows for one class (child class) to inherit the fields and methods of another class (parent class).

An inherited class is also called a subclass of its superclass (parent class).

Inheritance is considered one of the four pillars of OOP, along with abstraction, and encapsulation, and polymorphism.


// Parent Class
class Machine {
// Machine class member
// Child Class
class Car extends Machine {
// Car inherits traits from Machine
// Additional Car class members, functions, etc.
Edit this page on GitHub


Interested in helping build Docs? Read the Contribution Guide or share your feedback form.

Learn More on Codecademy

Edit this page on GitHub