Practice · 3 of 8
MCQ: What is printed?
CHALLENGE
Difficulty: advanced+25 XP
What is printed?
``java
public class Animal { public String speak() { return "..."; } }
public class Dog extends Animal {
public String speak() { return "woof"; }
public String fetch() { return "ball"; }
}
Animal a = new Dog();
System.out.print(a.speak());
`
A. woof
B. ...`
C. compile error: Animal has no speak
D. runtime error: cannot call speak on Dog
Print your answer as: the option letter, then your explanation of why it is correct and why each other option is wrong. First line must start with the letter.
Press Submit to check your solution.
Back to lesson: Practice: MCQ set 1: read the misconception