What is the output of the following code ?
class A: def foo(self): return self.bar() def bar(self): return 'A' class B(A): def bar(self): return 'B' obj1 = A() obj2 = B() print(obj2.bar(), obj2.foo())
B B
A A
A B
Error
obj2.bar() invokes bar() on class B so it prints B
For obj2.foo(), it invokes class A foo() method which internally returns bar(). for this call bar() of B will be overridden
Comment here: