I came across the following code in SCJP6 by kathy and bert,chpt:Object orientation,pg:151,the output is given as: a a a
but when i tried it out it had errors.
class Animal1
{
static void doStuff()
{
System.out.println("a ");
}
class Dog extends Animal1
{
static void doStuff()
{
System.out.println("d ");
}
public static void main(
String args[])
{
Animal1 [] a={new Animal1(),new Dog(),new Animal1()};
for(int x=0;x<a.length;x++)
a[x].doStuff();
}
}
}
Please compile and check it out.I got errors on line no:9,13 and 15.Sorry but the attachment was taking a lot of time to load
Thankyou.