Saturday, October 15, 2016

Difference between Abstract class and Interface

In this post will discuss about difference between Abstract class and Interface


abstract Classes    Interfaces
1 abstract class can extend only one class or one abstract class at a time interface can extend any number of interfaces at a time
2 abstract  class  can extend from a class or from an abstract class interface can extend only from an interface
3 abstract  class  can  have  both  abstract and concrete methods interface can  have only abstract methods
4 A class can extend only one abstract class A class can implement any number of interfaces
5 In abstract class keyword ‘abstract’ is mandatory to declare a method as an abstract In an interface keyword ‘abstract’ is optional to declare a method as an abstract
6 abstract  class can have  protected , public and public abstract methods Interface can have only public abstract methods i.e. by default
7 abstract class can have  static, final  or static final  variable with any access specifier interface  can  have only static final (constant) variable i.e. by default

0 comments:

Post a Comment