C
conrad
My book does not tell me this but when you
create a subclass of a class that contains,
as an example, private data members:
private String firstName;
private String lastName;
Then an instance of your subclass will
contain those members and to initialize
them you must invoke super to call
the class's constructor. This is
because constructors are not inherited
by a subclass.
Now my question: How does the
JVM /typically/ handle this?
I'll make clear what I mean by "this."
Let's call the two types: A
and B where B extends A.
When one creates B via the
new operator, the constructor of
B is invoked, and whether explicitly
or implicitly, super is included
as the first method invocation
in B. But if A's constructor is
not inherited by B, and A's constructor
modifies the private data members
inherited by B, does this mean
the call to super acts as a static
method of sorts in this context?
Could someone elaborate on this
and the correct way to think about
it?
create a subclass of a class that contains,
as an example, private data members:
private String firstName;
private String lastName;
Then an instance of your subclass will
contain those members and to initialize
them you must invoke super to call
the class's constructor. This is
because constructors are not inherited
by a subclass.
Now my question: How does the
JVM /typically/ handle this?
I'll make clear what I mean by "this."
Let's call the two types: A
and B where B extends A.
When one creates B via the
new operator, the constructor of
B is invoked, and whether explicitly
or implicitly, super is included
as the first method invocation
in B. But if A's constructor is
not inherited by B, and A's constructor
modifies the private data members
inherited by B, does this mean
the call to super acts as a static
method of sorts in this context?
Could someone elaborate on this
and the correct way to think about
it?