Difference Between Abstract Class and Interface in Java

A short comparison of an abstract class and interface in Java.

 Abstract Classes  Interfaces
 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
 abstract class can extend from a class or from an abstract class  interface can extend only from an interface
 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
 abstract class can have both abstract and concrete methods  interface can have only abstract methods
 abstract class can have protected , public and public abstract methods  interface can have only public abstract methods i.e. by default
 a class can extend only one abstract class  a class can implement any number of interfaces
 abstract class can extend only one class or one abstract class at a time  interface can extend any number of interfaces at a time

Leave a Reply