Differentiate between an abstract class and an interface

Abstract Class:

  • A class can extend only one abstract class
  • The members of abstract class can be private as well as protected.
  • Abstract classes should have subclasses
  • Any class can extend an abstract class.
  • Methods in abstract class can be abstract as well as concrete.
  • There can be a constructor for abstract class.
  • The class extending the abstract class may or may not implement any of its method.
  • An abstract class can implement methods.
Interface
  • A class can implement several interfaces
  • An interface can only have public members.
  • Interfaces must have implementations by classes
  • Only an interface can extend another interface.
  • All methods in an interface should be abstract
  • Interface does not have constructor.
  • All methods of interface need to be implemented by a class implementing that interface.
  • Interfaces cannot contain body of any of its method.
Posted on by