AlgoMaster Logo

Inheritance - Quiz

Last Updated: January 3, 2026

1 min read

Inheritance Exercises

31 quizzes

1
Code Completion

Complete the code so the OnlineCourse class correctly inherits from TrainingProgram

python
1
class OnlineCourse(TrainingProgram

Click an option to fill the blank:

2
Code Completion

Complete the code so that the Manager class initializes its Employee parent correctly using inheritance

python
1
super().(name, salary)

Click an option to fill the blank:

3
Code Completion

Complete the code so that the call uses super() to reach the next implementation of the process method in the MRO

python
1
result = super().()

Click an option to fill the blank:

4
Multiple Choice

Which option best describes inheritance in Python?

5
Multiple Choice

In single inheritance, a child class can inherit from how many direct parent classes?

6
Multiple Choice

Which class header correctly shows multiple inheritance?

7
Multiple Choice

In multilevel inheritance, what best describes the class relationships?

8
Multiple Choice

What does Method Resolution Order (MRO) determine?

9
Multiple Choice

In a multiple inheritance scenario, which function respects the MRO when calling parent methods?

10
Multiple Choice

What is method overriding?

11
Multiple Choice

Given class Manager(Employee): pass, what does Manager inherit?

12
Multiple Choice

How do you inspect the MRO of a class MyView?

13
Multiple Choice

Which statement about super() in single inheritance is correct?

14
Multiple Choice

When a subclass overrides a method, how can it still include the parent method’s behavior?

15
Sequencing

Order the steps to create a multilevel inheritance chain for a billing system where OnlineInvoice is the most specific class.

Drag and drop to reorder, or use the arrows.

16
Sequencing

Order the steps to safely extend a log method in a multiple inheritance mixin using super().

Drag and drop to reorder, or use the arrows.

17
Output Prediction

What is the output of this code using single inheritance and method overriding?

1class Notification:
2    def send(self):
3        return "Sending generic notification"
4
5class EmailNotification(Notification):
6    def send(self):
7        return "Sending email notification"
8
9note = EmailNotification()
10print(note.send())
18
Output Prediction

What is the output when using super() in a simple inheritance chain?

1class Task:
2    def run(self):
3        return "base"
4
5class TimedTask(Task):
6    def run(self):
7        return super().run() + " + timed"
8
9job = TimedTask()
10print(job.run())
19
Output Prediction

What is the output when multiple inheritance uses methods from both parents?

1class JsonSerializable:
2    def format(self):
3        return "json"
4
5class XmlSerializable:
6    def format(self):
7        return "xml"
8
9class Hybrid(JsonSerializable, XmlSerializable):
10    pass
11
12obj = Hybrid()
13print(obj.format())
20
Output Prediction

What will this code print with multilevel inheritance?

1class Transport:
2    def info(self):
3        return "transport"
4
5class LandTransport(Transport):
6    def info(self):
7        return super().info() + " on land"
8
9class Car(LandTransport):
10    pass
11
12vehicle = Car()
13print(vehicle.info())
21
Output Prediction

What is the output when the MRO is affected by class order?

1class A:
2    def who(self):
3        return "A"
4
5class B:
6    def who(self):
7        return "B"
8
9class C(A, B):
10    pass
11
12obj = C()
13print(obj.who())
22
Bug Spotting

Find the bug in this code that tries to use multiple inheritance for a user report.

Click on the line(s) that contain the bug.

python
1
class User:
2
    def get_name(self):
3
        return "Guest"
4
 
5
class Report:
6
    def get_name(self):
7
        return "Generic Report"
8
 
9
class UserReport(User, Report):
10
    def summary(self):
11
        title = super(Report, self).get_name()
12
        return f"Summary for {title}"
23
Bug Spotting

Find the bug in this multilevel inheritance code that prepares receipts.

Click on the line(s) that contain the bug.

python
1
class Document:
2
    def __init__(self, title):
3
        self.title = title
4
 
5
class Receipt(Document):
6
    def __init__(self, title, total):
7
        self.total = total
8
 
9
class OnlineReceipt(Receipt):
10
    def __init__(self, title, total, email):
11
        super().__init__(total, title)
12
        self.email = email
24
Matching

Match each inheritance-related term with its correct description.

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

25
Matching

Match each inheritance pattern with an example scenario.

Click an item on the left, then click its match on the right. Click a matched item to unmatch.

26
Fill in the Blanks

Complete the code so that PremiumUser correctly inherits and extends User with a custom greeting.

python
1
class User:
2
def greet(self):
3
return "Welcome user"
4
5
class PremiumUser(User):
6
def greet(self):
7
base =
8
return base +
9
10
member = PremiumUser()
11
print(member.greet())

Click an option to fill blank 1:

27
Fill in the Blanks

Complete the code to use multiple inheritance for a class that logs both to console and as debug.

python
1
class ConsoleLogger:
2
def log(self, message):
3
print("LOG:", message)
4
5
class DebugMixin:
6
def log(self, message):
7
super().log("DEBUG: " + message)
8
9
class DebugConsoleLogger(, ):
10
pass
11
12
logger = DebugConsoleLogger()
13
logger.log("started")

Click an option to fill blank 1:

28
Fill in the Blanks

Complete the code so that OnlineOrder correctly reuses Order's initializer in a multilevel chain.

python
1
class Order:
2
def __init__(self, amount):
3
self.amount = amount
4
5
class SpecialOrder(Order):
6
def __init__(self, amount, label):
7
super().__init__(amount)
8
self.label = label
9
10
class OnlineOrder(SpecialOrder):
11
def __init__(self, amount, label, email):
12
13
self.email = email
14
15
order = OnlineOrder(50, "gift", "a@example.com")
16
print(order.amount, order.label, )

Click an option to fill blank 1:

29
Fill in the Blanks

Complete the code so that AdminUser overrides describe but still includes BaseUser behavior.

python
1
class BaseUser:
2
def describe(self):
3
return "Base user"
4
5
class AdminUser(BaseUser):
6
def describe(self):
7
info =
8
return info + " with admin rights: " +
9
10
admin = AdminUser()
11
print(admin.describe())

Click an option to fill blank 1:

30
Hotspot Selection

Click the line that determines which save implementation is called according to the MRO.

Click on the line to select.

python
1
class BaseSaver:
2
    def save(self):
3
        print("Base save")
4
 
5
class JsonSaver(BaseSaver):
6
    def save(self):
7
        print("JSON save")
8
 
9
class LoggedSaver(BaseSaver):
10
    def save(self):
11
        print("Logging before save")
12
        super().save()
13
 
14
class AppSaver(LoggedSaver, JsonSaver):
15
    pass
16
 
17
saver = AppSaver()
18
saver.save()
31
Hotspot Selection

Click the line where method overriding occurs in this multilevel inheritance example.

Click on the line to select.

python
1
class Animal:
2
    def sound(self):
3
        print("Some sound")
4
 
5
class Dog(Animal):
6
    def sound(self):
7
        print("Bark")
8
 
9
class GuideDog(Dog):
10
    pass
11
 
12
pet = GuideDog()
13
pet.sound()