Java Reference
In-Depth Information
Although
sref
and
super
both refer to the same object using the type
Base
, only
super
will ignore the real class of the object to use the super-
class's implementation of
name
. The reference
sref
will act the same way
this
acts, selecting an implementation of
name
based on the actual class
of the object. Here is the output of
printName
:
this.name() = More
sref.name() = More
super.name() = Base