Categories:
.NET (961)
C (387)
C++ (185)
CSS (84)
DBA (8)
General (31)
HTML (48)
Java (641)
JavaScript (220)
JSP (109)
JUnit (31)
MySQL (297)
Networking (10)
Oracle (562)
Perl (48)
Perl (9)
PHP (259)
PL/SQL (140)
RSS (51)
Software QA (28)
SQL Server (5)
Struts (20)
Unix (2)
Windows (3)
XHTML (199)
XML (59)
Other Resources:
Differences between Interfaces and Abstract Classes
What's the difference between an interface and an abstract class?
✍: FYIcenter
An abstract class may contain code in method bodies, which is not allowed in an interface. With abstract classes, you have to inherit your class from it and Java does not allow multiple inheritance. On the other hand, you can implement multiple interfaces in your class.
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.
Neither Abstract classe or Interface can be instantiated.
2007-03-03, 5326👍, 0💬
Popular Posts:
How was XML handled during COM times? During COM it was done by using MSXML 4.0. So old languages li...
What is the FP per day in your current company?
What is the concept of XPOINTER? XPOINTER is used to locate data within XML document. XPOINTER can p...
Do You Know the Book "JUnit in Action"? You should know this book. It received some good reviews. Ti...
Do You Know the Book "JUnit in Action"? You should know this book. It received some good reviews. Ti...