What is the difference between interface and abstract class?
By: Karthik
- 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.
Archived Comments
1. What is the difference between an Interface and an Abstract Class?
A. 1.An abstract class ca
View Tutorial By: RAJA at 2015-06-26 17:28:31
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
What do you understand by JTA and JTS?
What do you understand by Synchronization?
Name the containers which uses Border Layout as their default layout?
What is bean managed transaction?
What are the call back methods in Session bean?
Can Entity Beans have no create() methods?
What is the difference between JTS and JTA?
What is difference between Java Bean and Enterprise Java Bean?
What is J2EE Connector architecture?
Tell me something about J2EE component?