what is the advantage of interface over abstract classes?

前端 未结 9 2080
野的像风
野的像风 2021-02-01 05:48

In Java, abstract classes give the ability to define both concrete and abstract methods whereas interfaces only give the ability to implement abstract methods. I believe overrid

9条回答
  •  南旧
    南旧 (楼主)
    2021-02-01 06:41

    The main advantages of interface over abstract class is to overcome the occurrence of diamond problem and achieve multiple inheritance. In java there is no solution provided for diamond problem using classes.For this reason multiple inheritance is block using classes in java. So to achieve multiple inheritance we use interface .

提交回复
热议问题