Recall & Review
beginner
What is an Abstract Base Class (ABC) in Python?
An Abstract Base Class is a class that cannot be instantiated directly and is designed to be a blueprint for other classes. It defines methods that must be created within any child classes.Click to reveal answer
beginner
How do you declare an abstract method in an Abstract Base Class?
You use the @abstractmethod decorator from the abc module to mark a method as abstract. This means subclasses must override this method.
Click to reveal answer
beginner
Why can't you create an instance of an Abstract Base Class?
Because it contains abstract methods that have no implementation, Python prevents creating objects from it to ensure subclasses provide the required method implementations.
Click to reveal answer
beginner
Which module in Python provides support for Abstract Base Classes?
The abc module provides the tools to create Abstract Base Classes and abstract methods.
Click to reveal answer
intermediate
What happens if a subclass does not implement all abstract methods of its Abstract Base Class?The subclass cannot be instantiated and will raise a TypeError until all abstract methods are implemented.Click to reveal answer
What decorator is used to declare an abstract method in Python?
✗ Incorrect
The @abstractmethod decorator marks a method as abstract, requiring subclasses to implement it.
Can you create an instance of an Abstract Base Class directly?
✗ Incorrect
Abstract Base Classes cannot be instantiated directly because they have abstract methods without implementation.
Which Python module must you import to use Abstract Base Classes?
✗ Incorrect
The abc module provides the Abstract Base Class functionality.
What error occurs if a subclass does not implement all abstract methods?
✗ Incorrect
Python raises a TypeError when trying to instantiate a subclass missing implementations of abstract methods.
Why use Abstract Base Classes?
✗ Incorrect
Abstract Base Classes ensure subclasses follow a specific interface by requiring method implementations.
Explain what an Abstract Base Class is and why it is useful in Python.
Think about how ABCs act like blueprints for other classes.
You got /4 concepts.
Describe the steps to create and use an Abstract Base Class in Python.
Focus on the code structure and rules for subclassing.
You got /5 concepts.