adplus-dvertising
frame-decoration

Question

What is the output of the following piece of code?
class A:
    def __init__(self, x= 1):
        self.x = x
class der(A):
    def __init__(self,y = 2):
        super().__init__()
        self.y = y
def main():
    obj = der()
    print(obj.x, obj.y)
main()

a.

Error, the syntax of the invoking method is wrong

b.

The program runs fine but nothing is printed

c.

1 0

d.

1 2

Answer: (d).1 2

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?