What is the difference between an interface and abstract class?

前端 未结 30 1831
情歌与酒
情歌与酒 2020-11-21 11:51

What exactly is the difference between an interface and abstract class?

30条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-11-21 12:24

    To give a simple but clear answer, it helps to set the context : you use both when you do not want to provide full implementations.

    The main difference then is an interface has no implementation at all (only methods without a body) while abstract classes can have members and methods with a body as well, i.e. can be partially implemented.

提交回复
热议问题