Home >> PHP >> What is difference between abstract class and interface in PHP

What is difference between abstract class and interface in PHP

1)-In abstract class this is not necessary that every method should be abstract but in interface every method is abstract.

2)-Single and multilevel inheritance is possible in abstract class but multiple and multilevel both type of inheritance is possible in interface.

3)-Abstract class you can define as well as declare methods but in interface you can only defined your method.

4)-Abstract class method could be public or protected both but interface method must be public only.

Post Your Comment

Next Questions
What is inheritance
Inheritance types
What is single inheritance
What is multiple inheritance
What is multilevel inheritance
How to use static method and property in inheritance
How to use self and parent with static
How to use self and parent without static
What is visibility
What is the difference between public, private, and protected
What is final
What is final class
What is final method
What is final variable
How to print half pyramid using star
How to print half pyramid using number
How to print inverted half pyramid using star
How to print inverted half pyramid using number
How to print half pyramid using one to ten number
How to print pyramid pattern using star
How to print half pyramid pattern using star
How to print half pyramid pattern using star after 180 degree rotation
display errors
string to array
array to string

Copyright ©2022 coderraj.com. All Rights Reserved.