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.
- 59,842
- 6
- 106
- 166
-
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.
- 698,415
- 94
- 811
- 1,216
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.
- 120,458
- 37
- 198
- 307
Yes when i decompiled a interface it had the modifier public abstract interface, and by definition they must be abstract to contain abstract methods.
- 737
- 2
- 9
- 26