-2

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?

user2451733
  • 11
  • 2
  • 4

4 Answers4

1

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.

Boris the Spider
  • 59,842
  • 6
  • 106
  • 166
1

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.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
1

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.

Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
-2

Yes when i decompiled a interface it had the modifier public abstract interface, and by definition they must be abstract to contain abstract methods.

Popgalop
  • 737
  • 2
  • 9
  • 26