In Java every method in an interface is implicitly abstract. But when at least one method in a class is abstract, that means that this class is abstract. Does that mean, that every interface is an abstract class?
4 Answers
I guess in some sort of way, yes. An abstract class can be used as an interface.
The issue is that a class can only extends on other class. A class can implements any number of interfaces.
So while abstract classes are similar to interfaces they are very different in reality.
- 57,395
- 6
- 106
- 161
-
1This is heavily explained and detailed in the possible dup question. – Luiggi Mendoza Jun 23 '13 at 13:15
-
@LuiggiMendoza ah yes, sorry. Hadn't noticed that one - voted to close as dup. – Boris the Spider Jun 23 '13 at 13:16
Does that mean, that every interface is an abstract class?
No. An interface (in Java 7 and earlier) can have no method implementations and can define no instance fields. An abstract class can do both. These are just some of the substantive differences.
- 669,072
- 92
- 771
- 1,162
But when at least one method in a class is abstract.
But its not a class,Its interface.
Instead you can say it's an abstract interface.
And finally :An interface is abstract by definition.
- 118,038
- 37
- 189
- 297
Yes when i decompiled a interface it had the modifier public abstract interface, and by definition they must be abstract to contain abstract methods.
- 717
- 2
- 9
- 25