Java abstract class and interface

Java abstract class and interface and their difference.

Abstract class

  • Can have both abstract and concrete methods;
  • A class can extend only one abstract class;
  • Can have protected, public and public abstract methods;
  • Can have static, final, or static final variables with any access modifier;
  • “is-a” relationship;
  • Cannot be instantiated;

Interface

  • Can have only abstract methods;
  • A class can implement multiple interfaces;
  • Can have only public abstract methods;
  • Can have only static final (constant) variables;
  • “like-a” relationship;
  • Can extend another interface;

References

java