Static methods overridden !!



Hi,

Consider the following piece of code

class AnimalTest {
public static void saySomething() {
System.out.println(" AnimalTest!");
}
}

class CowTest extends AnimalTest {
public static void saySomething1() {
System.out.println(" CowTest!");
}

public static void main(String[] args) {
AnimalTest[] animals = { new AnimalTest(), new CowTest() };
for (AnimalTest a : animals) {
a.saySomething();
}
new CowTest().saySomething();
}
}

Interestingly it prints out AnimalTest! thrice. I am wondering how did
it compile as CowTest doesn't have the method saySomething. Does the
static method got carried over to the subclass??

Regards,
Ravi

.