No, there is no good reason to create a public constructor for an abstract class: you cannot create an instance of your abstract class without first subclassing it, and the language deals with the corresponding corner cases for you.
In particular, if you want to anonymously subclass your abstract class, which means that you cannot provide your own constructor in a subclass, the language will provide you with one of them based on the signature of the protected constructor of your abstract base class
abstract class Foo { protected int x; protected Foo(int x) {this.x = x;} public abstract void bar(); } public static void main (String[] args) { Foo foo = new Foo(123) {
In the above example, it looks like the protected constructor of an abstract class is called, but it isnβt: the compiler builds a visible constructor for your anonymous class * that calls when you write new Foo(123) .
Demo version
* Actual visibility by default. Thanks, Pshemo, for discovering the error and delivering a good test case .
source share