9-1 Binding Consider the following method

9-1 Binding Consider the following method
1 / 1
9-1 Binding Consider the following method - slide 1 of 11 9-1 Binding Consider the following method - slide 2 of 11 9-1 Binding Consider the following method - slide 3 of 11 9-1 Binding Consider the following method - slide 4 of 11 9-1 Binding Consider the following method - slide 5 of 11 9-1 Binding Consider the following method - slide 6 of 11 9-1 Binding Consider the following method - slide 7 of 11 9-1 Binding Consider the following method - slide 8 of 11 9-1 Binding Consider the following method - slide 9 of 11 9-1 Binding Consider the following method - slide 10 of 11 9-1 Binding Consider the following method - slide 11 of 11
9-1 Binding Consider the following method invocation: obj.doIt(); At some point, this invocation is bound to the definition of the method that it invokes If this binding occurred at compile time, then that line of code would call the same

Related Topics

Download this presentation From Below

"9-1 Binding Consider the following method" is the property of its rightful owner. Permission is granted to download and print the materials on this website for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

Presentation Transcript

01
9-1 Binding Consider the following method invocation:
obj.doIt();
At some point, this invocation
is bound to the definition of the method that it invokes
If this binding occurred at compile time,
then that line of code would call the same method every time
However, Java defers method binding until run time –
this is called dynamic binding or late binding
Late binding provides flexibility in program design<br>
02
9-2 Polymorphism The term polymorphism literally
means "having many forms"
A polymorphic reference is a variable that can refer
to different types of objects at different points in time
The method invoked through a polymorphic reference
can change from one invocation to the next
All object references in Java
are potentially polymorphic<br>
03
9-3 Polymorphism Suppose we create the following reference variable:
Occupation job;
Java allows this reference to point
to an Occupation object, or
to any object of any compatible type
This compatibility can be established
using inheritance or using interfaces
Careful use of polymorphic references
can lead to elegant, robust software designs<br>