369
11.When we examine a derived class, we have access to more than just the meth-
ods and fields defined in the class. Explain.
12.What happens if a derived class defines an instance method with the same
form of heading as a method in its superclass?
13.What happens if a derived class defines a data field with the same name as a
data field in the superclass?
14.Distinguish between overriding and hiding.
15.Is it possible to remove a member that is inherited?
16.Overloading, overriding, and hiding are similar, yet different. Fill in the follow-
ing table showing whether the sentence describes overloading, overriding, or
hiding.
Situation Hiding Overriding Overloading Shadowing
a.A class method has the
same name and signa-
ture as a superclass
method.
b.An instance method
has the same name and
signature as a superclass
instance method.
c. A class has two methods
with the same name but
different signatures.
d.A field in a derived class
has the same name as
a field in its superclass.
e.An instance method has
the same name but a
different signature than
a superclass instance
method.
f. A method declares a
variable with the same
name as a field in the
class.
g.A method has a parameter
with the same name as a
field in the class.
17.What parts of a superclass’s interface cannot be inherited?