What is similarities/difference between an Abstract class and Interface?

By: Karthik Printer Friendly Format    

Answer: Differences are as follows:

•	Interfaces provide a form of multiple inheritance. A class can extend only one other class. 
•	Interfaces are limited to public methods and constants with no implementation. Abstract classes can have a partial implementation, protected parts, static methods, etc. 
•	A Class may implement several interfaces. But in case of abstract class, a class may extend only one abstract class. 
•	Interfaces are slow as it requires extra indirection to to find corresponding method in in the actual class. Abstract classes are fast.  

Similarities:


•	Neither Abstract classes or Interface can be instantiated. 




Most Viewed Articles (in Interview )

Interview Question: How is the MVC design pattern used in Struts framework?

Interview Question: Write code of any Action Class?

Interview Question: What is EJB container?

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

Interview Question: What are the call back methods in Entity bean?

Tell me something about J2EE component?

Why J2EE is suitable for the development distributed multi-tiered enterprise applications?

Can Entity Beans have no create() methods?

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

Interview Question: What is Struts?

Interview Question: Who makes the Struts?

Interview Question: Why it is called Struts?

Interview Question: What is Action Class?

Interview Question: What is Struts Validator Framework?

Interview Question: What is ActionForm?

Latest Articles (in Interview)

Comment on this tutorial