Hierarchical Inheritance
Hello everyone!
Today I am here to share Hierarchical Inheritance in Object Oriented Programming (OOP) in dart.

In hierarchical inheritance the parent class is shared by multiple child classes. The method inside the parent class is overridden by the child classes.

This is the parent class Device{}. I have defined a method poweron() inside the parent class. I have set an example print statement in the method. Now I will create some child classes which will override this method and they will show their own unique poweron message.

I have created this child class Mobile{}. In this class which extends the parent class Device I have overridden the method poweron(). I have displayed a different statement here by overriding the method from the parent class.

Similarly I have created this child class Laptop{}. In this child class I have overridden the poweron() method again and inside the method I have changed the statement accordingly.

Now in the main I have created the objects of both the child classes. Then I have called poweron() method from both the child classes. Each object has printed specific message with respect to the overridden method.

Here you can see the output of the program. Actually here in this program each child class inherited the parent class and then overridden the method of the parent class. This is how hierarchical inheritance works.
🎉 Congratulations!
Your post has been upvoted by the SteemX Team! 🚀
SteemX is a modern, user-friendly and powerful platform built for the Steem community.
🔗 Visit us: www.steemx.org
✅ Support our work — Vote for our witness: bountyking5
Visit: https://steemhop.org