OCPJP6-05-11 "Your life is in your hands, to make of it what you choose."
Priyadarshan Kelkar wrote:Please can someone explain why I get a class cast exception package com.scjp.practice.oo; class Animal{ void eat(){ System.out.println("Animal eating food"); } } class Horse extends Animal{ void eat(){ System.out.println("Horse eating grass "); } void bray(){ System.out.println("Eeeee haw haw haw"); } } public class TestInheritance { public static void main(String[] args) { Animal a = new Animal(); Horse h = new Horse(); Horse ha = (Horse) a; ha.eat(); } } Thanks in advance.
``Worry does not empty tomorrow of its sorrow; it empties today of its strength.''