Is there any reason to use an Interface instead of Abstract?

As far as i can tell, an Abstract can do everything an Interface can. Is there any reason to use an Interface over an Abstract?

Answers

  • edited July 2017

    Lots of reasons, but here is just one:

    "A Java class can implement multiple interfaces but it can extend only one abstract class."

    So if you wanted to make a Jumper interface, a Flyer interface, and a Digger interface, you could quickly compose classes that implement any of the seven combinations of those. You can't do that with Abstract.

    https://www.google.com/search?q=java+abstract+vs+interface

Sign In or Register to comment.