← Quiz: Inheritance: all 10 questions
Quiz: Inheritance · Question 7 of 10
What does this print? (code)
What does this print?
class Vehicle:
def describe(self):
return "vehicle"
class Car(Vehicle):
def describe(self):
return "car, a " + super().describe()
class SportsCar(Car):
pass
print(SportsCar().describe())
- A.vehicle
- B.car
- C.car, a vehicle
- D.SportsCar
Answer & explanation
Correct answer: car, a vehicle
SportsCar inherits Car's describe(), which extends Vehicle's version with super().
Can you get the rest right without peeking?
Take the timed Quiz: Inheritance quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →