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 )

What is difference between Java Bean and Enterprise Java Bean?

What is Collection API?

Interview Question: What is Action Class?

Interview Question: What is Struts Validator Framework?

Interview Question: What is ActionForm?

Interview Question: Is Struts compatible with other Java technologies?

Interview Question: Do you have to credit Struts on your own website?

Interview Question: How do I install Struts?

Interview Question: Does Struts include its own unit tests?

Interview Question: What about JSTL and JavaServer Faces ?

Interview Question: Can i map more than one table in a CMP?

Interview Question: How many EJB Objects are created for a Bean?

Interview Question: What is Message Driven Bean?

Interview Question: Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?

Types of Interviews

Latest Articles (in Interview)

Comment on this tutorial