Diff between Abstract Class and Interface
Diff between Abstract Class and Interface
S.No
|
Abstract Class
|
Interface
|
1
| For abstract class, a method must be declared as abstract. Abstract methods don’t have any implementation. | For the interface, all the methods by default are abstract methods only. So one cannot declare variables or concrete methods in interfaces. |
2
| The Abstract methods can declare with Access modifiers like public, internal, protected. When implementing in subclass these methods must be defined with the same (or a less restricted) visibility. | All methods declared in an interface must be public. |
3
| An abstract class can contain variables and concrete methods. | Interfaces cannot contain variables and concrete methods except constants. |
4
| A class can Inherit only one Abstract class and Multiple inheritances are not possible for Abstract class. | A class can implement many interfaces and Multiple interface inheritance is possible. |
Post a Comment