Java Reference
In-Depth Information
Summary of Key Concepts
A polymorphic reference can refer to different types of objects over time.
■
The binding of a method invocation to its definition is performed at run
time for a polymorphic reference.
■
A reference variable can refer to any object created from any class related
to it by inheritance.
■
The type of the object, not the type of the reference, is used to determine
which version of a method to invoke.
■
An interface name can be used to declare an object reference variable.
■
An interface reference can refer to any object of any class that implements
that interface.
■
A parameter to a method can be polymorphic, giving the method flexible
control of its arguments.
■
Implementing a sort algorithm polymorphically allows it to sort any
comparable set of objects.
■
Polymorphism allows us to apply a consistent approach to inconsistent
behaviors.
■
We should hone our design senses to identify situations that lend them-
selves to polymorphic solutions.
■
Establishing the relationship between a listener and the component it lis-
tens to is accomplished using polymorphism.
■
A file chooser allows the user to browse a disk and select a file to be
processed.
■
A color chooser allows the user to select a color from a palette or use RGB
values.
■
A slider lets the user specify a numeric value within a bounded range.
■
Exercises
Visit
www.myprogramminglab.com
to complete many of these Exercises
online and get instant feedback.
EX 10.1 Draw and annotate a class hierarchy that represents various
types of faculty at a university. Show what characteristics would
be represented in the various classes of the hierarchy. Explain
how polymorphism could play a role in the process of assigning
courses to each faculty member.
Search WWH ::
Custom Search