0

Inheritance question

I don’t understand why the answer to this code is 2, not 3 class A: def a(self): print (1) class B(A): def a(self): print(2) class C(B): def c(self): print(3) c = C() c.a()

30th Aug 2020, 5:43 PM
BEREDON Fadock
BEREDON Fadock - avatar
3 ответов
+ 2
Because you are not overriding a() in class C. That is c() in class C. So it will print the one which is inherited from class B and the value is 2.
30th Aug 2020, 5:50 PM
Avinesh
Avinesh - avatar
0
The answer is 2
12th Apr 2022, 7:14 PM
MBUGRI NATHANIEL AWINBE
- 1
What is the result of this code? class A: def a(self): print(1) class B(A): def a(self): print(2) class C(B): def c(self): print(3) c = C() c.a() ans:2
22nd Jan 2022, 3:50 AM
AKKALA KUSUMA