Loading...

The OOP Pillars Exam

A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
medium
Seniority
junior, mid

Problem

Implement a small class hierarchy that demonstrates all four pillars of object-oriented programming: encapsulation, inheritance, polymorphism, and abstraction. Create an abstract base class Animal with an abstract method speak(), then two concrete subclasses Dog and Cat. Each should encapsulate a private name and implement speak() differently. Return a list of speak() outputs from a list of animal instances.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a sandboxed Docker environment and grades it instantly.