Question 9
Not yet
answered
Flag question
What will be the output of the following code involving abstract classes?
abstract class Athlete {
abstract void train();
void rest() {
}
System.out.println("Athlete is resting");
}
class Boxer extends Athlete {
void train() {
System.out.println("Boxer is training");
}
}
public class Main {
public static void main(String[] args) {
Athlete athlete = new Boxer();
athlete.train();
athlete.rest();
}
}
○ A. The code will throw a runtime error because Athlete is abstract.
O B. Boxer is training
Boxer is resting
OC. Boxer is training
Athlete is resting
D. The code will not compile because Boxer doesn't implement all abstract methods.