Sunday, 5 February 2012

Difference between Interface and Abstract class

Interface:

  • Contains only abstract methods and the default access specifier is public. If we are specifying the method as shown in below.
                          void show();
       Internally it adds public abstract in front of the method.
                  i.e.,  public abstract void show();
  • Contains only final methods.
                  i.e.,  public static final int a;
  • Supports multiple Inheritance.
  • Inheritance is possible only with extends keyword.
Abstract class:
  • Contains abstract and concrete methods.
  • Can have final and non final methods.
  • Supports single inheritance only.
  • Supports extends and implements keywords.

No comments:

Post a Comment