adplus-dvertising
frame-decoration

Question

What is the output of the following piece of code?
class Test:
    def __init__(self):
        self.x = 0
class Derived_Test(Test):
    def __init__(self):
        Test.__init__(self)
        self.y = 1
def main():
    b = Derived_Test()
    print(b.x,b.y)
main()

a.

Error because class B inherits A but variable x isn’t inherited

b.

0 0

c.

0 1

d.

Error, the syntax of the invoking method is wrong

Answer: (c).0 1

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of the following piece of code?