Should an abstract class have at least one abstract method?

前端 未结 5 2086
眼角桃花
眼角桃花 2021-02-02 12:17

Is it necessary for an abstract class to have at least one abstract method?

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-02 12:55

    No, it is not necessary. You see this often back in "template method" design pattern, like HttpServlet, wherein each method already has default behaviour definied and you're free to override just one (or more) of them instead of all of them.

提交回复
热议问题