What will be the output of the following Python code?
class Test:
def __init__(self):
self.x = 0
class Derived_Test(Test):
def __init__(self):
self.y = 1
def main():
b = Derived_Test()
print(b.x,b.y)
main()
class Test:
def __init__(self):
self.x = 0
class Derived_Test(Test):
def __init__(self):
self.y = 1
def main():
b = Derived_Test()
print(b.x,b.y)
main()A. 0 1
B. 0 0
C. Error because class B inherits A but variable x isn't inherited
D. Error because when object is created, argument must be passed like Derived_Test(1)
Answer: Option C

Join The Discussion