[General boards] [Winter 2019 courses] [Fall 2018 courses] [Summer 2018 courses] [Older or newer terms]

Abstract classes


Do all abstract classes need to have a no-args constructor?


No, an abstract class could require arguments in the constructor. However, all subclasses of it must call super(arg1,…argn) correctly.


What if the subclass called only super() in its constructor?


If there isn’t a no-argument constructor in the parent class, calling super() would not compile.

Once you write a constructor for a class, java no longer provides the empty constructor for it.

So in this case, the program would not compile.