Question 15
Not yet
answered
Flag.
question
Given the following classes, what will be the output of the main method?
class Animal {
void makeSound() {
System.out.println("Animal makes sound");
}
}
class Dog extends Animal {
void makeSound() {
System.out.println("Dog barks");
}
}
public class Main {
public static void main(String[] args) {
}
Animal myDog = new Dog();
myDog.makeSound();
}
O a. Animal makes sound
O b. Compilation error
Oc. Dog barks
O d. Runtime error