What are the difference between abstract class and interface?
Answer Posted / khalid
A class implementing an interface must implement all of the
methods defined in the interface, while a class extending an
abstract class need not implement any of the methods defined
in the abstract class. Additionally, a class extending an
abstract class can implement an infinite number of it's own
methods.
another key difference between abstract class and interface
is that , in abstract class we can put sharable code, but
that is not possible in case of interface.
Another key difference between abstract class and interface
is that,
We can use interface as marker, ( we can use abstract class
also as abstract but then we can't extends any oter class,
so it is better always use interface as marker)
Marker===> An interface having no methods is called as a
Marker Interface.
| Is This Answer Correct ? | 24 Yes | 6 No |
Post New Answer View All Answers
How long do php sessions last?
What is overloading and overriding in php?
How to get the ip address of the client?
What are the two types of variables?
How to access standard error stream in PHP?
What are the two most common ways to start and finish a php block of code?
Which is better wamp or xampp?
What is the difference between echo print and print_r in php?
What are the encryption functions available in PHP?
What is substr() in php? And how it is used?
What is a controller php?
What is the difference between implode() and explode() in php?
Is php strongly typed?
What are the advantages and disadvantages of cascade style sheets?
How can we check the value of a given variable is alphanumeric?