722
- a.Protected members
b.They are automatically part of the interface.
9.Data fields and methods that are publicor protected
12.The method in the derived class overrides the method in the superclass.
15.No, you cannot remove a member, but you can hide it by covering it with a mem-
ber of the same name.
Situation Hiding Overriding Overloading Shadowing
A class method has the same X
name and signature as a
superclass method.
An instance method has the X
same name and signature as a
superclass instance method.
A class has two methods with X
the same name but different
signatures.
A field in a derived class has X
the same name as a field in its
superclass.
An instance method has the X
same name but a different
signature than a superclass
instance method.
A method declares a variable X
with the samename as a field
in the class.
A method has a parameter X
with the same name as a
field in the class.
Chapter 7 Programming Warm-Up Exercises
2.public classMyName extendsYourName
{
intmyField; // myField is an instance field
publicMyName(intmyField) // Constructor with a parameter
// that shadows the instance field
{
this.myField = myField; // Assign the parameter to
// the instance field
}
}