//******************************************************************** // Talking.java Author: Lewis and Loftus // // Demonstrates the use of an interface for polymorphic references. //******************************************************************** class Talking { //----------------------------------------------------------------- // Instantiates two objects using an interface reference and // invokes one of the common methods. Then casts the interface // reference into a class reference to invoke its unique method. //----------------------------------------------------------------- public static void main (String[] args) { Speaker current; current = new Dog(); current.speak(); current = new Philosopher ("I think, therefore I am."); current.speak(); ((Philosopher) current).pontificate(); } }