Link to home
Start Free TrialLog in
Avatar of Manikandan Thiagarajan
Manikandan ThiagarajanFlag for India

asked on

Explain Difference Between Interface and abstract class

Explain Difference Between Interface and abstract class
ASKER CERTIFIED SOLUTION
Avatar of reijnemans
reijnemans
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

interface is a collection of methods which need to be implemented by any class which cliams to implement the interface

abstract class is a class which has one or more methods which were not implemented and should be implemenetd in the
non-abstract sub-class of this class

so those are in fact very different  entities.

interface does not include any iomplementation of any methods - only signatures
which need to be followed by implmeneting classes

abstract class can have implementation of all methods with the exception of one
and abstrcat class can have instance variable and everything

interfcae can have only method signtures and constants and nothing else

Basically interface is much more abstract thing - it just specifies certain number of brehaviours
taht the object should demonstrate, otherwise it does not specify much about the actual
"meat" of the object

Abstract class on the contrary will often specify almost everything about the object, but say one or two
behaviors leaves open, so that some subclasses of this abstract class implement these behaviors in one way and other
suvbclasses  - in another way