Well done!
You have completed Understanding Classes, Instances, and Attributes in Object-Oriented Programming Quiz!
Quiz Question 1 of 5
If a class attribute total_orders
was added to track the number of coffee orders and was updated in the __init__()
method every time a new order instance was created, what would be the most appropriate way to ensure total_orders
correctly reflects all created instances?
Choose the correct answer below:
-
A
Increment
total_orders
directly inside the__init__()
method usingself.total_orders += 1
. -
B
Ensure
total_orders
is reset to 0 before creating any new orders. -
C
Use
CoffeeOrder.total_orders += 1
inside__init__()
to increment the value. -
D
Manually update
total_orders
every time a new instance is created.