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 the difference between JTS and JTA?

Interview Question: What is Action Class?

What is Collection API?

Interview Question: What is EJB container?

Interview Question: What is lazy loading?

Question: What is a Hidden Comment in JSP?

What do you understand by a J2EE module?

Differentiate between .ear, .jar and .war files.

What is Deployment Descriptor?

Name the containers which uses Border Layout as their default layout?

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

Interview Question: How do I install Struts?

Interview Question: What is the difference between sessioncontext and entitycontext?

Interview Question: What is abstract schema?

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?

Latest Articles (in Interview)

Comment on this tutorial