What is the example of inheritance in Java?

Example 1: Java Inheritance eat(); Here, labrador is an object of Dog . However, name and eat() are the members of the Animal class. Since Dog inherits the field and method from Animal , we are able to access the field and method using the object of the Dog .

Sizin İçin Seçtik  What is an aggregation and give example on aggregation?

Leave a Reply

Your email address will not be published. Required fields are marked *

What is the example of inheritance in Java?

Example 1: Java Inheritance eat(); Here, labrador is an object of Dog . However, name and eat() are the members of the Animal class. Since Dog inherits the field and method from Animal , we are able to access the field and method using the object of the Dog .

Sizin İçin Seçtik  How much does Udemy pay affiliate?

Leave a Reply

Your email address will not be published. Required fields are marked *