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 types of comments are available in the JSP?

What are implicit Objects available to the JSP Page?

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

Interview Question: What is Action Class?

Interview Question: Who wrote Struts?

Interview Question: Does Struts include its own unit tests?

Interview Question: Is there a particularly good IDE to use with Struts ?

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

Interview Question: Do ActionForms have to be true JavaBeans?

Interview Question: What are the optional clauses in EJB QL?

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

Interview Question: What is local interface. How values will be passed?

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

Question: How would you go about analyzing performance of an application?

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

Latest Articles (in Interview)

Comment on this tutorial