Python Programming - Polymorphism - Discussion

Discussion Forum : Polymorphism - General Questions (Q.No. 23)
23.
Consider the following code:
class Animal:
    def speak(self):
        pass

class Duck(Animal):
    def speak(self):
        return "Quack!"

class Cow(Animal):
    def speak(self):
        return "Moo!"
What concept is demonstrated in this code?
Method overloading
Method overriding
Operator overloading
Polymorphism
Answer: Option
Explanation:
This code demonstrates method overriding, where the subclasses provide specific implementations for a method defined in the superclass.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.