How would you override a method defined in a superclass in Python?

  • By creating a new method with the same name in the subclass
  • By importing the superclass method
  • By renaming the superclass method
  • By using the @override decorator
In Python, to override a method defined in a superclass, you create a new method with the same name in the subclass. This new method in the subclass will replace (override) the behavior of the superclass method.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *