Quiz · Inheritance and polymorphism · lesson 4 of 10
Quiz — whose method runs
What does the program print?
public class Main {
public static void main(String[] args) {
Animal a = new Cat();
a.sound();
}
}
class Animal {
void sound() { System.out.print("..."); }
}
class Cat extends Animal {
@Override void sound() { System.out.print("Meow"); }
}