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 )

Tell me something about J2EE component?

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

What do you understand by a container in J2EE?

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?

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

Interview Question: Do you have to credit Struts on your own website?

What are implicit Objects available to the JSP Page?

The output of System.out.println(5<<2) in Java

What is the difference between interface and abstract class?

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

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

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

What is the difference between Session Bean and Entity Bean?

Question: What is an output comment in JSP?

Interview Question: What is Deployment descriptor?

Latest Articles (in Interview)