difference between abstract and interface?Why abstract class needed?
June 1, 2010 at 3:36 PM
Difference between Abstract class and Interface:
1)An interface represents only the boundaries of a class/classes that implement the interface, and contains no functionality while An abstract class represents a base class, from which other classes can inherit functions.
2)All methods are abstract in Interface while in Abstract class, at least one method is abstract.
3)In an interface, members are public by default while abstract class may contain non-public members.
4)Interface can be used to achieve multiple inheritance while abstract class can be used as a single inheritance.
5) Interface is more flexible than abstract class because one class can only "extends" one super class, but "implements" multiple interfaces.
Need of abstract class
It helps us to organize our classes based on common methods. An abstract class lets you put the common method names in one abstract class without any implementation.