Well done!
You have completed Understanding Class Relationships and Inheritance in Python Quiz!
Quiz Question 1 of 5
Considering the following Python code snippet, what is the most significant impact of using inheritance in this context?
class Device:
def power_on(self):
print("Device is powering on")
class Smartphone(Device):
def power_on(self):
print("Smartphone is powering on")
phone = Smartphone()
phone.power_on()
Choose the correct answer below:
-
A
The
Device
class’spower_on
method will be called first, followed by theSmartphone
class’s method. -
B
The method in the
Smartphone
class will override theDevice
class method, leading to theSmartphone
'spower_on
method being called. -
C
The
power_on
method in theSmartphone
class will not be executed since it's inherited from theDevice
class. -
D
The program will produce an error because the
Smartphone
class attempts to override a method from theDevice
class.