LearnFrenzy
Sign in Take a free test

Inheritance and Polymorphism · Inheritance and Polymorphism MCQ · Question 4

A parent method calling an overridden method Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 4 Back to Exercise

Animal.describe() calls self.speak(); Dog overrides speak(). Which speak runs for Dog().describe()?

  • A Animal.speak – describe is defined in Animal
  • B Both
  • C Neither; it raises an error
  • D Dog.speak – self is the Dog object Correct
Correct Answer: Option D

Method lookup starts at the object's actual class, wherever the calling code lives.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links