Wednesday, September 28, 2011

What is the difference between Interface and Abstract class


  1. Interfaces used to implement the inheritance relationship between the non related classes that do not belongs to the same hierarchy. By using interface you can specify what a class must do but not how it does.
  2. Abstract classes can be used to implement the inheritance relationship between the classes that belongs to the same hierarchy.
  3. abstract class must have sub classes, where as interfaces have no sub classes.
  4. All the methods declared in the interface are abstract , where as abstract class must have one abstract method and others may be concrete.
  5. In abstract class keyword abstract must be used for method, where as in interface we need not use the keyword for methods.
  6. An abstract class can only extend one class, where as an interface can extend more than once
Find more about abstract and interfaces click here

No comments:

Post a Comment