Quiz: Object Relationships and Data Model
Evaluate your understanding of composition, inheritance, polymorphism, dunder methods, and data containers through a series of challenging applied questions.
We'll cover the following...
We'll cover the following...
Technical Quiz
1.
We are designing a SmartHome class that contains a list of Appliance objects. Which implementation best demonstrates composition and delegation for a turn_off_all method?
A.
class SmartHome(Appliance):
def turn_off_all(self):
self.power_off()
B.
class SmartHome:
def __init__(self, apps):
self.apps = apps
def turn_off_all(self):
for app in self.apps:
app.power_off()
C.
class SmartHome:
def turn_off_all(self, apps):
for a in apps:
a.power_off()
D.
class SmartHome:
def __init__(self):
self.app = Appliance()
1 / 11
...