10 - Polymorphism Flashcards
Polymorphism
having many forms
A polymorphic reference is a …
reference variable that can refer to different types of objects at different points in time.
The binding of a method invocation to its definition is performed at …
run time for a polymorphic reference. Also called late binding, or dynamic binding.
A reference variable can refer to…
any object created from any class related to it by inheritance.
What is used to determine which version of a method to invoke?
The type of the object, not the type of the reference
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.
How does the selection sort algorithm sort?
The selection sort algorithm sorts a list of values by successively putting particular values in their final, sorted positions.
Implementing a sort algorithm polymorphically….
allows it to sort any comparable set of objects.
Comparable
is an interface that includes only one method, compareTo which is designed to return an integer that is less that zero, equal to zero, or greater than zero if the executing objects is less than, equal or greater to the object its being compared.
Polymorphism allows us to apply a …
consistent approach to inconsistent behaviors.