Abstract classes and methods in Java, Inheritance

后端 未结 5 971
星月不相逢
星月不相逢 2021-02-14 15:22

I have class B, which inherits from class A. The superclass A is abstract, containing one abstract method. I don\'t want to implement the abstract method in class B, therefore I

5条回答
  •  野性不改
    2021-02-14 16:00

    So, the question is: Which is preferred when sub classing an abstract class in java and don't want to provide implementation?

    a) mark subclass as abstract too

    b) mark subclass as abstract too AND re-write the method signature marked as abstract?

    I would go for the first one:

    a) Mark subclass as abstract too.

    The former has already the abstract method declaration, there is no point in repeating it.

提交回复
热议问题