Classes & Objects · Question 10 · Medium

Three classes in a chain each extend fee() using super(). What does the last class return?

class Base:
    def fee(self):
        return 1000

class Hostel(Base):
    def fee(self):
        return super().fee() + 500

class AC(Hostel):
    def fee(self):
        return super().fee() * 2

print(AC().fee())
  1. 3000
  2. 2000
  3. 2500
  4. 1500
Answer and explanation

Answer: A. 3000

Explanation: AC.fee calls Hostel.fee, which calls Base.fee and gets 1000, then adds 500 to make 1500. AC doubles that result to 3000.

Previous: The child class Student defines its own __init__ and does not call the… · Next: The Point class defines __eq__. What do == and is give for two separately…

Practise classes & objects

Try a fresh set of classes & objects questions with an explanation after every answer, free and without signing up: Classes & Objects practice. Or sit a full placement mock test.

More classes & objects questions

More python practice

Exceptions & Files · Built-ins & Standard Library · Variables, Types & Operators · Python Strings · Lists & Tuples · Dictionaries & Sets · Conditions & Loops · Functions & Scope

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge