Home > database >  What is the difference between 'implements' keyword and 'extends' keyword in dar
What is the difference between 'implements' keyword and 'extends' keyword in dar

Time:08-02

I couldn't understand the difference between these two keywords.

By using extends we can get features from parent class. I think implements does that too.

First I thought the difference is overriding methods but with extends I can do that.(I might be wrong)

Is the difference of these two keywords about overriding methods or what? Thank you

CodePudding user response:

extends means we get the implementation of a given class and we can then override members if we want our own implementation for certain variables or methods. You can also add new variables and methods.

implements means you get nothing from the class you implement from. But you promise that your class will be compatible with the interface of the class you are implementing. So no, you are not getting any implementation from the super class and you need to implement everything or declare your class abstract.

  •  Tags:  
  • dart
  • Related