Enforcing Concrete Implementations

Medium Abstraction & Interfaces
Solve in Playground →

Problem Statement

Create an abstract class `Vehicle` with an abstract method `wheels()`. Create a subclass `Car` that implements `wheels()` to return 4. Create a subclass `Bike` that implements `wheels()` to return 2. Instantiate both and print their wheel counts.

Input Format

None

Output Format

Print the wheel counts on separate lines.

Constraints

None

Sample Output

4
2

Explanation

Abstract classes enforce a strict contract: any subclass must implement the abstract methods before it can be instantiated.

Starter Code

import abc

class Vehicle(abc.ABC):
    # Define abstract method wheels
    pass

class Car(Vehicle):
    # Implement wheels
    pass

class Bike(Vehicle):
    # Implement wheels
    pass

if __name__ == '__main__':
    # Instantiate both and print wheels()
    pass

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used