Difference between abstract and interface in Java

One of the most repetitive programming interview question is “what’s the difference between abstract and interface classes?”. To answer this question I have had search the internet to come with a complete answers in bullet points. I tried to cover as much as I can. Below is the end result of my findings.

  • A Interface class is like a table of content in a book that gives you an overview. It also can be called as an empty shell which just contains signature of methods (definition).  Abstract on the other hand has implementation and is more expensive to use.
  • Interface can be implemented whereas abstract can be inherited.
  • Multiple interfaces can be implemented which is a good replacement for multiple inheritance in programming languages which do not support it (Java).
  • Abstract can have member variables, constants, methods. Interface can only have methods declarations.
  • In interfaces only public access modifier is permitted to use, abstract doesn’t have such a limitation.
  • Abstract can have static method, in interface static is not allowed (except Java 1.8).

In the last point, I mention about having static methods are not allowed in interface except Java 1.8. It is interesting to know that in Java 1.8 you can define static method in interface and use it. You can read more about it here,



Leave a Reply