This is the code that I'm dealing with:
class Animal {
public void hide() {
System.out.println("The hide method in Animal.");
}
public void override() {
System.out.println("The override method in Animal.");
}
public static void clank()
{
System.out.println("Clank in Animal");
}
}
and
public class Cat extends Animal {
public void hide() {
System.out.println("The hide method in Cat.");
}
public void override() {
System.out.println("The override method in Cat.");
}
public static void clank()
{
System.out.println("Clank in Cat");
}
public static void main(String[] args) {
Cat myCat = new Cat();
Animal myAnimal = new Cat();
myAnimal.hide();
myAnimal.override();
myAnimal.clank();
}
}
The output of this code is:
The hide method in Cat.
The override method in Cat.
Clank in Animal
why does declaring both clank methods as static doesn't allow the clank in Animal to be overridden? should the output be "Clank in Cat"? Thanks!