Q. What will be the result of the following code?

Code:
class Base:
    def greet(self):
        print("Hello from Base")

class Derived(Base):
    pass

d = Derived()
d.greet()
  • (A) Error
  • (B) Hello from Base
  • (C) Hello from Derived
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (B) Hello from Base
Explanation: The `Derived` class inherits the `greet` method from `Base`, so it works as expected.
Explanation by: Mr. Dubey
The `Derived` class inherits the `greet` method from `Base`, so it works as expected.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
71
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
82%
Success Rate