English, asked by gurnoor7944, 1 year ago

What isv is a relationship inheritence with real life example?

Answers

Answered by rishabhpandey9777
1

share

Inheritance (IS-A) vs. Composition (HAS-A) Relationship

Last update on April 14 2018 06:14:57 (UTC/GMT +8 hours)

Description

One of the advantages of an Object-Oriented programming language is code reuse. There are two ways we can do code reuse either by the vimplementation of inheritance (IS-A relationship), or object composition (HAS-A relationship). Although the compiler and Java virtual machine (JVM) will do a lot of work for you when you use inheritance, you can also get at the functionality of inheritance when you use composition.

IS-A Relationship:

In object-oriented programming, the concept of IS-A is a totally based on Inheritance, which can be of two types Class Inheritance or Interface Inheritance. It is just like saying "A is a B type of thing". For example, Apple is a Fruit, Car is a Vehicle etc. Inheritance is uni-directional. For example, House is a Building. But Building is not a House.

It is a key point to note that you can easily identify the IS-A relationship. Wherever you see an extends keyword or implements keyword in a class declaration, then this class is said to have IS-A relationship.

Thank you

Hope it helps

Similar questions