What is the difference between interface and abstract class?

By: Karthik Emailed: 1696 times Printed: 2188 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

  • interface contains methods that must be abstract; abstract class may contain concrete methods.
  • interface contains variables that must be static and final; abstract class may contain non-final and final variables.
  • members in an interface are public by default, abstract class may contain non-public members.
  • interface is used to "implements"; whereas abstract class is used to "extends".
  • interface can be used to achieve multiple inheritance; abstract class can be used as a single inheritance.
  • interface can "extends" another interface, abstract class can "extends" another class and "implements" multiple interfaces.
  • interface is absolutely abstract; abstract class can be invoked if a main() exists.
  • interface is more flexible than abstract class because one class can only "extends" one super class, but "implements" multiple interfaces.
  • If given a choice, use interface instead of abstract class.

Interview Home | All Interview Tutorials | Latest Interview Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(1)


1. View Comment

What is the difference between an Interface and an Abstract Class?
A. 1.An abstract class can have instance methods that implement a default behavior
B. 2. An Interface can only declare constants and Interface methods, but cannot implement default behavior and and all methods are implicitly abstract...
C. 1. An abstract class is a class which may have the use all flavors of class members (private, of protected, et) but has some abstract methods.
2. An Interface has all public members and no implementation.
C. both A and B
D. none of these


View Tutorial          By: RAJA at 2015-06-26 17:28:31

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Karthik
What is the difference between interface and abstract class?
What are the life-cycle methods of JSP?
What is JSP Scriptlet?
What is JSP declaration?
What types of comments are available in the JSP?
What is expression in JSP?
What is JSP Output Comments?
What are all the different scope values for the tag?
What are implicit Objects available to the JSP Page?
What is the difference between jsp:forward and response.sendRedirect(url),?.
What is the difference between jsp:include page and @ include file?
What do you understand by JSP Actions?
What are Access Specifiers available in Java?
Explain the different forms of Polymorphism.
Explain the Polymorphism principle.

More Tutorials in Interview
What is J2EE?
What do you understand by a J2EE module?
Tell me something about J2EE component?
What are the contents of web module?
Differentiate between .ear, .jar and .war files.
What is the difference between Session Bean and Entity Bean?
Why J2EE is suitable for the development distributed multi-tiered enterprise applications?
What do you understand by a container?
What are the services provided by a container?
What are types of J2EE clients?
What is Deployment Descriptor?
What do you understand by JTA and JTS?
What is JAXP?
What is J2EE Connector architecture?
What is difference between Java Bean and Enterprise Java Bean?

More Latest News
Most Viewed Articles (in Interview )
Interview Question: Is Decorator an EJB design pattern?
Interview Question: How is the MVC design pattern used in Struts framework?
Interview Question: Why it is called Struts?
Interview Question: What is ActionForm?
Interview Question: How do I install Struts?
Interview Question: Why are some of the class and element names counter-intuitive?
Interview Question: What is EJB client JAR file?
Interview Question: What is the difference between sessioncontext and entitycontext?
Interview Question: What is lazy loading?
Interview Question: What is local interface. How values will be passed?
Question: Difference between forward and sendRedirect in JSP?
What is J2EE?
Tell me something about J2EE component?
What are the contents of web module?
Differentiate between .ear, .jar and .war files.
Most Emailed Articles (in Interview)
Interview Question: How does Struts work?
Interview Question: What are the call back methods in Entity bean?
Question: Difference between forward and sendRedirect in JSP?
What is the difference between JTS and JTA?
What is the difference between jsp:include page and @ include file?
Interview Question: How is the MVC design pattern used in Struts framework?
Interview Question: Who makes the Struts?
Interview Question: Where can I get a copy of Struts?
Interview Question: If the framework doesn't do what I want, can I request that a feature be added?
Interview Question: Why does EJB needs two interfaces(Home and Remote Interface)?
Getting started with Interview
Question: How would you go about analyzing performance of an application?
What is J2EE Connector architecture?
What are the call back methods in Session bean?
What is Collection API?