Python Programming - Classes - Discussion

Discussion Forum : Classes - General Questions (Q.No. 21)
21.
Consider the following Python code:
class Animal:
    def speak(self):
        return "Animal speaks"

class Dog(Animal):
    def speak(self):
        return "Dog barks"
What is the concept illustrated in this code?
Encapsulation
Inheritance
Polymorphism
Abstraction
Answer: Option
Explanation:
The code demonstrates the concept of inheritance, where the `Dog` class inherits from the `Animal` class, acquiring its methods and attributes.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.