Should an abstract class have at least one abstract method?

java_geek picture java_geek · Feb 17, 2010 · Viewed 33.8k times · Source

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

Answer

matt b picture matt b · Feb 17, 2010

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.