Page 1 of 1

About Question enthuware.ocajp.i.v7.2.907 :

Posted: Tue Dec 25, 2012 10:21 am
by ETS User
If there is no visible constructor, the control, will not call default constructor for super class?

Re: About Question enthuware.ocajp.i.v7.2.907 :

Posted: Tue Dec 25, 2012 2:27 pm
by admin
Your question is not clear. If there is no visible constructor in which class? the super class or the subclass?

When you instantiate a sub class, the subclass's constructor is called and that constructor can invoke any constructor of its superclass. If subclass's constructor does not call super class's constructor explicitly, then the compiler puts a call to super(); as the first line of the subclass's constructor.

HTH,
Paul.

Re: About Question enthuware.ocajp.i.v7.2.907 :

Posted: Fri Jan 03, 2014 11:16 am
by cyril090
Hi!

I have some doubts about:

"Note that if a subclass class constructor doesn't explicitly call the super class constructor, the compiler automatically inserts super(); as the first statement of the base class constructor. So option 5 is not needed."

I would say:

"Note that if a subclass class constructor doesn't explicitly call the super class constructor, the compiler automatically inserts super(); as the first statement of the subclass class constructor. So option 5 is not needed."

Peace.

Re: About Question enthuware.ocajp.i.v7.2.907 :

Posted: Fri Jan 03, 2014 11:43 am
by admin
You are right. This has now been fixed.

thank you for your feedback!
Paul.