What is the difference between interface and abstract class?

By: Karthik Viewed: 169 times  Printer Friendly Format    


  • interface contains methods that must be abstract; abstract class may contain concrete methods.
  • interface contains variables that must be static and final; abstract class may contain non-final and final variables.
  • members in an interface are public by default, abstract class may contain non-public members.
  • interface is used to "implements"; whereas abstract class is used to "extends".
  • interface can be used to achieve multiple inheritance; abstract class can be used as a single inheritance.
  • interface can "extends" another interface, abstract class can "extends" another class and "implements" multiple interfaces.
  • interface is absolutely abstract; abstract class can be invoked if a main() exists.
  • interface is more flexible than abstract class because one class can only "extends" one super class, but "implements" multiple interfaces.
  • If given a choice, use interface instead of abstract class.


Most Viewed Articles (in Interview )

Tell me something about J2EE component?

What is the difference between JTS and JTA?

What is the difference between jsp:include page and @ include file?

Interview Question: What is Action Class?

Interview Question: What is the difference between EAR, JAR and WAR file?

What is Deployment Descriptor?

Explain garbage collection?

Interview Question: What is ActionForm?

Interview Question: What about JSTL and JavaServer Faces ?

Interview Question: Why are some of the class and element names counter-intuitive?

Interview Question: What is the difference between ejbCreate() and ejbPostCreate?

Interview Question: What is difference between EJB 1.1 and EJB 2.0?

Interview Question: What is lazy loading?

Interview Question: What is the difference between find and select methods in EJB?

Interview Question: What is the difference between Message Driven Beans and Stateless Session beans?

Latest Articles (in Interview)

Comment on this tutorial