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 )

What is transient variable?

What is the difference between interface and abstract class?

What is the difference between Session Bean and Entity Bean?

What are the services provided by a J2EE container?

Interview Question: What is the difference between EAR, JAR and WAR file?

What are the call back methods in Session bean?

Interview Question: What is difference between EJB 1.1 and EJB 2.0?

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

What is Collection API?

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

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

What is difference between Java Bean and Enterprise Java Bean?

Interview Question: What is EJB container?

Interview Question: Do ActionForms have to be true JavaBeans?

Interview Question: Why do we need Struts?

Latest Articles (in Interview)