Dart Abstract Class and Abstract Method Example. Object Oriented Tutorial #9.6

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

Dart tutorial for Flutter. Explore how to implement Abstract Class and Abstract Method with Demo sample code. Also, explore properties of Abstract Classes and Methods. Also, learn how to override methods while inheriting Abstract class in child or subclass.

.
Please donate and support my work
(If you think my free tutorials are better than paid ones :)

Free Programming courses:

Free Flutter course:

Free Android courses:

More free programming courses:

Check out my website:

Let's get in touch! [Sriyank Siddhartha]

---- Thank you for your love and support ----
Рекомендации по теме
Комментарии
Автор

The use of an abstract class and method: Now, suppose you have a parent Animal class. And two children, Cat and Dog, extending Animal. We may want to create Cat and Dog objects, but we almost will never be creating any Animal objects. We only have the Animal class for the children to inherit from it. Since there's no use for instantiating an Animal class on its own, we make it abstract. And an abstract class cannot be instantiated in the main() function. Now let's see abstract methods.. A Cat and a Dog may have the same function named "makeNoise()", but both of them make different noises. So an abstract method is defined in the abstract class, and we override that method in the child classes. I hope this helps. :)

SheikhAmeen
Автор

Lockdown time learning dart . very similar to java. Thanks for the series. I like your plain voice.

sagarghare
Автор

Firstly, you r awesome at understanding.
What is the use of abstract class then?

aman
Автор

simple clear and precise. Awesome. God bless you man.

nasirmehmood_
Автор

Hi, Sir I want to know what are application and benefit of abstract classes?

itubezonebd
Автор

What's the difference from using an interface other than you can implement multiple interfaces.

jemjem
Автор

Sir if we can't instantiate an abstract class then why it instantiated when we instantiate the child class of it.

ujjawalk
Автор

Sir as you said, after inheriting the abstract class and its method, we can use another method in abstract class with body but what is the purpose of using a method with body in an abstract class when it can not be instantiated ?

avi
Автор

yes, I wanted to know that if we are about to create another class as we can't use abstract class directly, then why create abstract class?

korouiromcha
Автор

abstract class can have constructs with just declarations

noob_gamer
Автор

sir, in Abstract Class you have declared x and y, can we use Abstract Class instance variables in Circle child class ?

venkateshwarlumotamari
Автор

You did not mention anything about method declaration. what about overriding an abstract method with different list of arguments??? Is that allowed? Hmm.

kasandrop
Автор

abstract extends, interface implements :)

jadoooh
Автор

If you are designing large functional units, use an abstract class. If you want to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members.


mazenalsakkaf
Автор

Because the constructor is called when the child class is instantiated.

ujjawalk
Автор

its not mandatory to have abstract method in abstract class. then y we use abstract class. you are only telling how to type syntax. but u never show an example or scenario where it can work.


try this code with out abstract method in abs, class it

void main() {
var dog = Dog();
dog.shape();
}

abstract class Animal {
void shape() {

}
}

class Dog extends Animal {
void shape();
}

TevaIllathaAani
Автор

Can someone explain the exact usage of method() :someNewWork()
{ \\Whatever}

What is the real world usage of the stuff after colon?

akshaybhandari
visit shbcf.ru