Abstract Class Vs Interface
A class can implement more than one number of interfaces but a subclass can at most use only one abstract class.
An interface can not provide any code, just the signature, but an abstract class can provide complete default code.
An abstract class can declare or use any variables while an interface is not allowed to do so.
Constructor declaration can be done for the abstract class but interface can not.
Access specifiers can be used for the abstract classes but not for the interfaces as all the members of interface are implicitly public.
Interfaces are used to define the peripheral abilities of a class, whereas an abstract class defines the core identity of a class and so it is used for the objects of the same type.
No fields can be defined in the interfaces but in abstract classes it can be.
CodeProject
No comments:
Post a Comment