🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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())
  1. A.vehicle
  2. B.car
  3. C.car, a vehicle
  4. 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 →