S.No | Abstract Class | Interface Class |
1 | Abstract class - method must be declared as abstract. Abstract methods doesn’t have any definition. The sub class (extend class) can have the definition for those abstract method. | Interface - all the methods by default are abstract methods only. So one cannot declare variables in interfaces. The sub class (implement class) can have all method definition for those methods. |
2 | The Abstract methods can declare with Access modifiers like public, internal, protected. | All methods declared in an interface must be public. |
3 | Abstract class can contain variables and concrete methods. | Interfaces cannot contain variables and concrete methods, but we can possible to define the constants. |
4 | An abstract class can Inherit only one Abstract class and Multiple inheritance is not possible for Abstract class. | A class can implement many interfaces and Multiple interface inheritance is possible. |
Difference between abstract class and interface in php
Subscribe to:
Post Comments (Atom)
good
ReplyDelete