---
title: "Can you explain the concept of inheritance in object-oriented programming?"  
description: "Can you explain the concept of inheritance in object-oriented programming?"  
author: "SundarLal Sharma"  
published: 2024-04-01  
updated: 2024-04-03  
canonical: https://answers.mindstick.com/qa/111687/can-you-explain-the-concept-of-inheritance-in-object-oriented-programming  
category: "programming language"  
tags: ["programming language"]  
reading_time: 2 minutes  

---

# Can you explain the concept of inheritance in object-oriented programming?



## Answers

### Answer by Baishakhi Ghosh

## Overview:

[**Inheritance**](https://www.mindstick.com/articles/23301/interface-in-oops) is a fundamental concept in [**object-oriented programming (OOP)**](https://en.wikipedia.org/wiki/Object-oriented_programming) that allows a class (known as the child or derived class) to acquire homes and direct from another class (alluded to as the decide or base gloriousness). This allows the making of progressive connections between examples, working with code reuse, and selling a secluded and arranged plan.

Legacy lays out a "is-a" dating between preparing, wherein the inferred polish is a particular variant of the [base class](https://www.mindstick.com/interview/1817/what-is-a-base-class). The inferred class acquires every one of the qualities (fields) and methods (capacities) of the base class, called the superclass, and can likewise frame extra ascribes and systems specific to its own personal ability.

![OOPs: Inheritance and Polymorphism | by Mukesh Chaudhary | Medium](https://miro.medium.com/v2/resize:fit:904/1*rddNpQyOeBl_jQ3Rmet5dg.png)

The sentence [structure](https://www.mindstick.com/blog/302153/structured-vs-unstructured-data-key-differences) for forcing legacy fluctuates depending on the programming [language](https://www.mindstick.com/startup/28/preply-the-fast-growing-platform-transforming-language-learning) anyway, and typically incorporates the utilization of the stretches out watchword to connote the parent class from which the youngster class acquires. For example, in Java:

class Animal {

void eat(){

System.out.println ("Animal is eating...") ;

}

}

For this situation, the Canine class acquires the consume() [procedure](https://www.mindstick.com/blog/304484/explain-the-sql-stored-procedures) from the Creature class. The canine polish can likewise frame its own personal techniques, comprehensive of bark(), correspondingly to the acquired strategies.

Legacy advances [code reusability](https://www.mindstick.com/articles/337478/the-role-of-design-patterns-in-enhancing-code-reusability) with the guide of allowing generally normal usefulness to be depicted in an unmarried style and divided between several subclasses. It moreover works with [polymorphism](https://www.mindstick.com/articles/32/polymorphism), a vital statute of OOP, wherein things of different preparation might be managed conversely principally founded on their normal superclass.

Notwithstanding, unbalanced or misleading utilization of legacy can bring about firmly coupled and convoluted progressive systems, making the codebase [challenging](https://www.mindstick.com/news/2240/in-a-u-s-lawsuit-challenging-facebook-s-virtual-reality-agreement-mark-zuckerberg-will-testify) to comprehend and keep. It's significant to utilize legacy wisely and pick organization over legacy when reasonable to harvest a more adaptable and particular plan.

Read more: [What is object-oriented programming](https://answers.mindstick.com/qa/111490/what-is-object-oriented-programming)


---

Original Source: https://answers.mindstick.com/qa/111687/can-you-explain-the-concept-of-inheritance-in-object-oriented-programming

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
