I’m novice to java and learning my way through it.
Is it necessary to have a argument constructor for superclass if subclass have argument constructor, what happens if subclass have argument constructor and superclass have default no-argument constructor?
I’m novice to java and learning my way through it. Is it necessary to
Share
It would not be a problem – but you can explicitly invoke
super()in the constructor of the subclass (as the first statement in the subclass’ constructor), or let the compiler do it for you – as it implicitly invokes an argmentless constructor (if one exists) as the first step.Doing one of these will “let the class know” how to build the super class.
Example: