What is similarities/difference between an Abstract class and Interface?
By: Karthik
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.
Archived Comments
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?