Inheritance Example In Java

According to Oracle(R) docs, Inheritance. A class that is derived from another class is called a subclass (also a derived classextended class, or child class). The class from which the subclass is derived is called a superclass (also a base class or a parent class).

The simplest example of this is the Student is a Person. In this example the Student class simply copies the isAPerson() method of the Person class.

Is the student is also a person? Yes!

Just like class, Interface can also inherits traits from another Interface. In our next example the EcoBag class implements Basket which implements Container and all the methods defined by both Basket and Container is implemented by EcoBag class.

It is true that ecoBag has handle
It is true that ecoBag can contain something

Leave a Reply

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