DART METHOD OVERRIDING - POLYMORPHISM - Dart Flutter Programming Tutorial

preview_player
Показать описание
Dart Method Overriding

What is Polymorphism?

The polymorphism is a combination of the two Greek words poly, which means many and morph means morphing into different forms or shapes. Together, polymorphism means the same entity can be used in various forms. In the programming aspect, the same method can be used in different classes. This technique makes programming more intuitive and more accessible.

For example - We have Shape class to define the shape of the object. The shape can be the circle, rectangle, square, straight line, etc. So here the goal is common, but the approach is different.

The method overriding is a technique to achieve polymorphism. Sometimes, we want a subclass object to give different results for the same method when subclass object invokes it. This can be done by defining the same method again in subclass.

Method Overriding

When we declare the same method in the subclass, which is previously defined in the superclass is known as the method overriding. The subclass can define the same method by providing its own implementation, which is already exists in the superclass. The method in the superclass is called method overridden, and method in the subclass is called method overriding.

Explore the concept of runtime Polymorphism such as Method Overriding during Inheritance in Dart. Furthermore, explore what is super keyword and how to use it to call super class methods i.e. methods present in Super Parent class from Child Subclass.

Рекомендации по теме
join shbcf.ru