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 )

How to define an Abstract class?

Question: What is a Hidden Comment in JSP?

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?

Interview Question: Why aren't the Struts tags maintained as part of the Jakarta Taglibs project ?

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

What is the difference between interface and abstract class?

What are the life-cycle methods of JSP?

What is JSP Scriptlet?

What is JSP declaration?

What types of comments are available in the JSP?

What is expression in JSP?

What is JSP Output Comments?

What are all the different scope values for the tag?

What are implicit Objects available to the JSP Page?

What is the difference between jsp:forward and response.sendRedirect(url),?.

Latest Articles (in Interview)

Comment on this tutorial