Computer Science, asked by popstarastha4712, 9 months ago

What is inheritance with an example?

Answers

Answered by Anonymous
16

Inheritance is a powerful mechanism by which one class acquires the properties of another class.

For example:-

Consider a base class Vehicle. Different vehicles have different features and properties. However, some features are common to all the vehicles. The derived class of this base class can be any type of vehicle.

Hope it helps❣

Answered by smartbrainz
3

Inheritance is an important feature of Object Oriented Programming.

  • Inheritance is an important aspect of Object Oriented Programming concept. It refers to the ability of an object to inherit characteristics from other classes of objects.
  • The class that inherits the features is called as a sub-class and the class from which the features are taken , is called as the super-class.
  • The main purpose of Inheritance it to introduce code re-usability. For example - Students, books and teachers can be sub-classes of a super-class 'School', meaning that the code that applies to all sub-classes, can be consolidated into a super-class called 'School'. Now if any changes are made to the code of super-class 'school', then the changes shall be cascaded to all sub-classes automatically.

To know more about Inheritance, visit:

https://brainly.in/question/1551467

 

Similar questions