Bird
Raised Fist0

Identify the error in this code:

medium📝 Debug Q6 of Q15
Python - Inheritance and Code Reuse
Identify the error in this code:
class Vehicle:
    def start(self):
        print('Vehicle started')

class Car(Vehicle):
    def start(self):
        super.start()
        print('Car started')

c = Car()
c.start()
ACar class should not override start()
BMissing return statement in start()
Csuper.start() should be super().start()
DVehicle class must inherit from object explicitly
Step-by-Step Solution
Solution:
  1. Step 1: Check super() usage

    In Python 3, super() must be called with parentheses to return a proxy object.
  2. Step 2: Identify error

    The code uses super.start() which is invalid syntax; it should be super().start().
  3. Final Answer:

    super.start() should be super().start() -> Option C
  4. Quick Check:

    super() requires parentheses to call methods [OK]
Quick Trick: Always use super() with parentheses to call parent methods [OK]
Common Mistakes:
MISTAKES
  • Calling super.method() without parentheses
  • Forgetting to override methods properly
  • Assuming explicit object inheritance is required in Python 3

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes