javaabstract-classabstractabstract-methods

Should an abstract class have at least one abstract method?


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


Solution

  • The subject of this post and the body ask two different questions:

    1. Should it have at least one abstract member?
    2. Is it necessary to have at least one abstract member?

    The answer to #2 is definitively no.

    The answer to #1 is subjective and a matter of style. Personally I would say yes. If your intent is to prevent a class (with no abstract methods) from being instantiated, the best way to handle this is with a privateprotected constructor, not by marking it abstract.