TGViewer
Coding Interview Preparation Coding Interview Preparation @coding_interview_preparation · 5.9K subscribers
Post #1138 579
Inheritance in Object Oriented Programming (OOP)

A concept that allows one class to inherit the properties and behaviours (i.e., fields and methods) of another class.
Inheritance promotes code reusability and helps in structuring and organizing code.

In inheritance we have:
1. Base Class (Parent Class or Superclass):
The class whose properties and methods are inherited by another class.

2. Derived Class (Subclass or Child Class):
The class that inherits from a base class is known as the derived class or subclass.

Syntax:
class BaseClass {

};

class DerivedClass : access-specifier
BaseClass {

};



Imagine we have a "Vehicle" class. This class defines what all vehicles have in common, like wheels and an engine.
Now, if we want to create a "Car" class, you can make it inherit from the "Vehicle" class.

So, inheritance helps us avoid repeating the same code and makes it easier to create new classes that share common features with existing classes.
  • ❤ 1
More from @coding_interview_preparation
  1. Oct 12, 2026Java Coding Interview Questions Easy 1. Reverse a string without using a built-in reverse…
  2. Oct 10, 2026100 SQL interview questions
  3. Oct 8, 2026If you're prepping for system design interviews, this repo is gold It contains a curated,…
  4. Oct 6, 2026document post
  5. Oct 4, 2026💼 Why Your Resume Gets Rejected Before a Human Reads It You may have good skills and proj…
  6. Oct 2, 2026🧠 Coding Myths You Should Stop Believing There's a lot of advice online about learning to…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →