What is the output of the following Python code snippet?
class A:
def f(self): return 'A'
class B(A):
def f(self): return 'B'
print(B().f())
-
A
A
-
B
Error
-
C
B
Correct answer
-
D
None
11 views
Explanation
Overriding with a call to super() combined with a different return shows the child result.
Doubts & discussion
Not sure why the answer is C? Ask here and get an explanation.
Ask a doubt about this MCQ