简体   繁体   中英

Why we are declaring the class as abstract class it has only concrete methods in it?

Abstract class means, it has both abtract methods and concrete methods but even if it has only concrete methods, it is just look like a normal methods only right. And why we are declaring the class as the abstract without any abtract methods?

On some cases, you do want to have some shared logic/fields/methods between several classes, but you do not want the base class to be instanciated by itself, only the extending classeses.

For such use-cases, abstract class, even without any abstract methods, can do the trick

它可以是实现某些接口的基类:所有方法都是具体的,但并非所有接口方法都被实现。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM