No. It means, if there is default constructor (or not), extended class implicitly (by default) adds a call to a base class constructor with no parameters "super()". If such a constructor does not exist in base class - it fails to compile.Dev Choudhary wrote:1)That means every class should have default constructor (with no parameters) or user's defined constructor with no parameters ?
Liutauras Vilda wrote:No. It means, if there is default constructor (or not), extended class implicitly (by default) adds a call to a base class constructor with no parameters "super()". If such a constructor does not exist in base class - it fails to compile.
If there is no argument constructor or default one, you need to add call with "super" and parameters list explicitly.
As I said, sorry if I wasn't fully clear, if you don't have and don't want default or no arguments constructor in your super class, you define constructor you want with parameters list, AND in this case, you need to add explicit call to that constructor in your extended class. Because compiler implicitly can add only call to a no parameter constructor (for your convenience).Dev Choudhary wrote:What if we does not require default (no-arguement) constructors at all and require only paramerized constructors ?
Dev Choudhary wrote:Ok, that means even if do not call super class constructor explicitly from the sub class (by using 'super' keyword), then also an implicit call is made to super class default constructor from sub class?
One last doubt - Many a times such concepts (as that of problem I mentioned above), are not mentioned straight-forward in the books (as far as the books I've referred, don't know about others). So how to get acquainted with such hidden or detailed concepts ?
Yes. That word "also" just confusing and shouldn't be there, apart from that - correct.Dev Choudhary wrote:Ok, that means even if do not call super class constructor explicitly from the sub class (by using 'super' keyword), then also an implicit call is made to super class default constructor from sub class ?
If you're interested to grasp technical part of Java language, you could read one of OCAJP 7/8 certifications books. These books usually concentrates on providing you with technical details of Java programming language, rather than teaching you how to program.Dev Choudhary wrote:So how to get acquainted with such hidden or detailed concepts ?
Stephan van Hulst wrote:
Dev Choudhary wrote:Ok, that means even if do not call super class constructor explicitly from the sub class (by using 'super' keyword), then also an implicit call is made to super class default constructor from sub class?
Yes.