no need to define ass method in both classes. you should cast the ass
method . because reference type is anymal.
ie. ((Horse)b).ass();//careful on putting parenthesis
On Sun, Jul 26, 2009 at 7:13 PM, ali googerdi wrote:
>
> It's because you didn't define the ass method in Animal class but you
It's because you didn't define the ass method in Animal class but you
have define eat in both classes.
On Jul 26, 4:29 pm, ANUJ KUMAR wrote:
> class TestAnimals {
> public static void main (String [] args) {
> Animal a = new Animal();
> Animal b = new Horse(); //Animal ref, but a Horse object
>
I think u need modifier for anuj() method.
On Jul 26, 8:29 pm, ANUJ KUMAR wrote:
> class TestAnimals {
> public static void main (String [] args) {
> Animal a = new Animal();
> Animal b = new Horse(); //Animal ref, but a Horse object
> a.eat(); // Runs the Animal version of eat()
> b.eat(); // R