Difference between abstract class with all method abstract and interface?

后端 未结 7 1830
感动是毒
感动是毒 2020-12-29 14:05

I had an interview where interviewer asked me first what is the difference between abstract class with all the methods abstract and an interface.

I replied that if

7条回答
  •  滥情空心
    2020-12-29 14:36

    Interfaces are the natural way of creating a contract because they force you to implement the methods they define.

    Besides that, you can implement as many as you want in the case you want to add new interfaces to your class.

提交回复
热议问题