Monday, July 5, 2010

Difference between abstract class and interface

Interface
Abstract class
Interfaces can not implement any methods. i.e. All methods are abstract.
Abstract class can implemented some of its methods. i.e. Some methods may not be abstract.
Cannot contain constructors.
Can contain constructors.
Can be implemented by classes or extended by other interfaces.
Can be extended by classes only.
Classes may Implement  several interfaces
Classes can extend only one abstract class.
Class implementing an interface has to implement all the methods of the interface
Class extending an abstract class does not need to  implement all the methods of the abstract class.
Access specifier is either public or default.
Any access specifier can be used.

No comments:

Post a Comment