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

  • google app store apple app store
  • ✖

      Question

      The following Python code attempts to call a method from

      the parent class, but it's using an outdated or incorrect syntax. How should it be corrected? class Parent:     def greet(self):         print("Hello from Parent") class Child(Parent):     def greet(self):         print("Hello from Child")         # Parent.greet(self) # Problematic c = Child() c.greet()
      A Change `Parent.greet(self)` to `super().greet()`. Correct Answer Incorrect Answer
      B Change `Parent.greet(self)` to `self.greet()`. Correct Answer Incorrect Answer
      C Remove the `greet` method from `Child`. Correct Answer Incorrect Answer
      D Change `Parent` to `Base`. Correct Answer Incorrect Answer
      E The syntax `Parent.greet(self)` is correct and works. Correct Answer Incorrect Answer

      Solution

      The correct answer is A

      Practice Next
      ask-question