/**
 * Illustration of class cast exceptions.
 *
 * @author Drue Coles
 */
public class PetDemo5 {

    public static void main(String[] args) {
        Pet myPet = new Dog("Isaak", 12945); 
       
        GuardDog duke = new GuardDog("Duke", 23614, true);
        duke.attackStranger();
        
        // The downcast is necessary for compilation.
        // But what happens at runtime?
        GuardDog duchess = (GuardDog) myPet;
        duchess.attackStranger();        
    }
}