Programming Tutorials

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

By: Karthik in Interview Tutorials on 2012-06-16  

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. 





Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Interview )

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

Interview Question: Who wrote Struts?

Question: What is a Hidden Comment in JSP?

Explain the Encapsulation principle.

What is Collection API?

What is Deployment Descriptor?

Interview Question: Where can I get a copy of Struts?

Interview Question: What is the difference between ejbCreate() and ejbPostCreate?

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

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

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

Interview Question: What is re-entrant. Is session beans reentrant. Is entity beans reentrant?

Interview Question: Can I invoke Runtime.gc() in an EJB?

Interview Question: What is Local client view in EJB?

Interview Question: What is the difference between JavaBean and EJB?

Latest Articles (in Interview)