Computer Science, asked by taranbirsingh5654, 10 months ago

Write a program in Java to show multilevel inheritance in which Animal class should be inherited by Dog class and BabyDog class should be inherited from Dog class.Display the respective information for each class.(Assume suitable information).

Answers

Answered by tannoypathak
0

Inheritance in java is a mechanism in which one object acquires all the properties and behaviors of parent object.

Using inheritance, we can create a general class that defines traits common to a set of related items. This class can then be inherited by other, more specific classes, each adding those things that are unique to it.

The logic behind inheritance in java is that we can create new classes that from existing classes. When you inherit from an existing class, you can reuse methods and fields of parent class, and you can add new methods and fields also.

Inheritance represents the IS-A relationship, also known as parent-child relationship.

I hope it will help you

Similar questions