What is the output of the following code ?
class SuperClass:
def printme(self):
print('Welcome to python class')
def referer(self):
self.do_action()
class SubClass(SuperClass):
pass
p = SubClass()
p.printme()
What is the output of the following code ?
class SuperClass:
def printme(self):
print('In SUPER class method')
class SubClass(SuperClass):
def printme(self):
print('In SUB class method')
p = SubClass()
p.printme()
What is the output of the following code ?
class SuperClass:
def printme(self):
print('In SUPER class method')
class SubClass(SuperClass):
def printme(self):
print('In SUB class method')
SuperClass.printme(self)
p = SubClass()
p.printme()
What is the output of the following code ?
class A:
def __init__(self):
self.__a = 1
self.b = 5
def display(self):
print(self.__a, self.b)
class B(A):
def __init__(self):
super().__init__()
self.__a = 2
self.b = 7
p = B()
p.display()
What is the output of the following code ?
class A:
def test(self):
print("test of A is called")
class B(A):
def test(self):
print("test of B is called")
super().test()
class C(A):
def test(self):
print("test of C is called")
super().test()
class D(B, C):
def test3(self):
print("test of D is called")
p = D()
p.test()
What is the output of the following code ?
class A:
def __init__(self, x=47):
self._x = x
class B(A):
def __init__(self):
super().__init__(98)
def printme(self):
print(self._x)
obj = B()
obj.printme()
What is the output of the following code ?
class A:
def __init__(self, x=47):
self.__x = x
class B(A):
def __init__(self):
super().__init__(98)
def printme(self):
print(self.__x)
obj = B()
obj.printme()
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())
What is the output of the following code ?
class A:
def __init__(self, x=6):
self.k = x
class B(A):
def __init__(self, y=9):
super().__init__()
self.l = y
obj = B()
print(obj.k, obj.l)
What is the output of the following code ?
class A:
pass
class B(A):
pass
class C(B):
pass
obj = C()
print(isinstance(obj, A))