Re: acces of members of subclass



On Jul 28, 1:37 pm, Mark Space <marksp...@xxxxxxxxxxxxxx> wrote:
Lew wrote:
Daniel Moyne wrote:
- Sub may have itw own typical constructor with its own parameters
where of
course super(...) is not present.

'super()' is always present, if only implicitly.  If you do not provide
one, the compiler inserts a call to the no-argument 'super()' for you.

Er, lots of classes have no zero-argument constructor, so Daniel is
correct.  Any given sub-class, in the general case, cannot rely on the
presence of a super() call.

From the JLS:
If a constructor body does not begin with an explicit constructor invocation and the
constructor being declared is not part of the primordial class Object, then the
constructor body is implicitly assumed by the compiler to begin with a superclass
constructor invocation "super();", an invocation of the constructor of its direct
superclass that takes no arguments.

The call to super() is *always* present. Any given class, in the
general case, can rely on the presence of super() call. Daniel and
you are not correct.

--
Lew

.



Relevant Pages