A subclass needs a constructor if the superclass does not have a default constructor (or has one that is not available for the subclass). If the subclass does not have a constructor at all, the compiler will automatically create a public constructor, which simply calls the default constructor of the superclass.
Regarding calling super() : the first thing every constructor should do is either call another constructor in the same class by calling this() (possibly with some arguments), or call the constructor of its superclass by calling super() (again, possibly with arguments). None of these calls can go anywhere. If the constructor does not start with any, the compiler automatically inserts the call into super() (without any arguments). Therefore, if you want, you must refer to the default superclass constructor (and, many times, this is the case), then you do not need to explicitly call super() yourself.
There is also one situation where you do not need to provide a constructor (in fact, you cannot provide one), even if the superclass does not have a default constructor. This case (described in section 15.9.5.1 of the Language Language Sepcification section ) is to create an anonymous subclass of the class using a non-standard constructor; the compiler will automatically create a constructor with the correct arguments and call the corresponding (non-standard) superclass constructor. For instance:
class X { public X(int value) { ... }
Then myX will be an instance of an anonymous subclass of X with a constructor generated by the compiler that takes an int argument and calls super(intArg) .
source share