Should an abstract class have at least one abstract method?

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

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

5条回答
  •  南笙
    南笙 (楼主)
    2021-02-02 12:58

    No - you can declare a class abstract without having any abstract methods. It may not make any sense conceptually for an instance of that class to exist, or you may want to ensure that only subclasses of that class can be instantiated (for whatever reason)

提交回复
热议问题