📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    In Python, if a method in a subclass has the same name

    as a method in its superclass, which method will be called when invoked on an object of the subclass?
    A The superclass method, unless explicitly called with `super()`. Correct Answer Incorrect Answer
    B Both methods will be called. Correct Answer Incorrect Answer
    C The subclass method, overriding the superclass method. Correct Answer Incorrect Answer
    D A `TypeError` will be raised. Correct Answer Incorrect Answer
    E The choice depends on the order of inheritance. Correct Answer Incorrect Answer

    Solution

    The correct answer is C

    Practice Next
    ask-question