Inheritance in OOP: Everything you Need to Know

Rashad Shirizada
5 min readJun 12, 2022
Source

OOP (Object-oriented programming) uses inheritance as one of its fundamental programming features. Inheritance allows you to create classes that are derived from other classes, and then use those derived classes in your code as if they were the same type as the parent class. There are a number of different inheritance models available, each with their own particular advantages and disadvantages, but all fall into two major categories: Single Inheritance and Multi-Level Inheritance (aka Multiple Inheritance). Let’s take a look at these in more detail…

Inheritance

In Object-Oriented Programming, inheritance is a way of reusing code from parent classes by extending child classes. In other words, by creating new classes that extend existing ones. If a class extends another class, we say that it inherits all its attributes and methods. This system allows for very precise customization since only code that needs to be changed must be modified. The process by which a class receives or invokes inherited code is called calling or invoking super() . You can use inheritance to create specialized objects with specific characteristics. For example, if you have an object named dog , you can create specialized dogs such as GermanShepherdDog , Dalmatian , Poodle . It’s easier than having to program every single characteristic of each type of dog…

--

--