The class of the object.
It makes sense that the object's method is invoked, since, after all, the method is part of the object and the method uses the object's data. Here is an example from the previous chapter:
The reference variable card is used three times,
each time with a different class of object.
Since Card is a parent to the three different classes,
the variable card can be used for each.
. . . . // class definitions as before
public class CardTester
{
public static void main ( String[] args )
{
Card card = new Holiday( "Amy" );
card.greeting(); //Invoke a Holiday greeting()
card = new Valentine( "Bob", 3 );
card.greeting(); //Invoke a Valentine greeting()
card = new Birthday( "Cindy", 17 );
card.greeting(); //Invoke a Birthday greeting()
}
}
Could a reference variable Valentine val refer to
a Holiday object?