Suppose A is a subclass of B, to invoke the __init__ method in B from
Practice Inheritance Questions – Suppose A is a subclass of B, to invoke the __init__ method in B from A, you write _________.
Practice Inheritance Questions – Suppose A is a subclass of B, to invoke the __init__ method in B from A, you write _________.
Practice Inheritance Questions – To check whether an object o is an instance of class A, use _________.
Practice Inheritance Questions – What is the output of the following code?
class ParentClass:
def __init__(self):
self.__x = 1
self.y = 10
def print(self):
print(self.__x, self.y)
class ChildClass(ParentClass):
def __init__(self):
super().__init__()
self.__x = 2
self.y = 20
c = ChildClass()
c.print()
Practice Inheritance Questions – Analyze the following code:
class A:
def __init__(self, i = 0):
self.i = i
class B(A):
def __init__(self, j = 0):
self.j = j
def main():
b = B()
print(b.i)
print(b.j)
main()