Java Reference
In-Depth Information
able can refer to any object that implements its interface. When you call a method on an
object through an interface reference, it is the version of the method implemented by the
object that is executed. This process is similar to using a superclass reference to access a
subclass object, as described in
Chapter 7
.
The following example illustrates this process. It uses the same interface reference vari-
able to call methods on objects of both
ByTwos
and
ByThrees
.