Why would you ever use an interface instead of an abstract class?

With an abstract class, you can have unimplemented methods and then implemented methods. With an interface, you can only have unimplemented methods.Can somebody tell me, then, why Joe Doe would want to use an interface over an abstract class?
[256 byte] By [Hypera] at [2007-11-26 17:39:48]
# 1
http://www.javaworld.com/javaworld/javaqa/2001-04/03-qa-0420-abstract.html
kevjavaa at 2007-7-9 0:07:58 > top of Java-index,Java Essentials,Java Programming...
# 2

[url=http://www.javaworld.com/javaworld/javaqa/2001-04/03-qa-0420-abstract.html]Abstract classes vs. interfaces: When does it make sense to choose an abstract class over an interface?[/url]

[url=http://www.javaworld.com/javaworld/javaqa/2001-08/03-qa-0831-interface.html]Abstract classes and interfaces practicum: Move from theory to practice on when to employ abstract classes vs. interfaces[/url]

[url=http://java.sun.com/developer/JDCTechTips/2001/tt1106.html#tip2]Tech Tips: ABSTRACT CLASSES VS. INTERFACES[/url]

~

yawmarka at 2007-7-9 0:07:58 > top of Java-index,Java Essentials,Java Programming...
# 3
Joe Doe would know that using an abstract class would force the user to extend that class and due to single-inheritance amoung classes, only that class. Using interfaces lets the implementor using a class-inheritance of his choice - would Joe Doe argue.
BIJ001a at 2007-7-9 0:07:58 > top of Java-index,Java Essentials,Java Programming...
# 4

> Joe Doe would know that using an abstract class would

> force the user to extend that class and due to

> single-inheritance amoung classes, only that class.

>

> Using interfaces lets the implementor using a

> class-inheritance of his choice - would Joe Doe argue.

That Joe Doe is a smart guy. I bet he uses Google.

kevjavaa at 2007-7-9 0:07:58 > top of Java-index,Java Essentials,Java Programming...
# 5
> That Joe Doe is a smart guy. I bet he uses Google.Yes and he does not waste his time answering googleable questions on forums...
BIJ001a at 2007-7-9 0:07:58 > top of Java-index,Java Essentials,Java Programming...
# 6

> Can somebody tell me, then, why Joe Doe would want to

> use an interface over an abstract class?

The main reason is a limitation in the Java inheritance model namely that you can inherit one class only but as many interfaces as you want. This can be characterized as: single inheritance of implementation but multiple inheritance of type. The latter is considered the most important in OO design so the fact that you can inherit implementation from from one source only isn't that much of a limitation really .

So to make use of multiple inheritance of type in Java you need to use interfaces (and possibly one class).

BIJ001a at 2007-7-9 0:07:58 > top of Java-index,Java Essentials,Java Programming...