Analyze the following code:
class&nbsp

Loading

Choose the correct option.

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()

A. Class B inherits A, but the data field in i in A is not inherited.
B. Class B inherits A and automatically inherits all data fields in A.
C. When you create an object B, you have to pass an integer such as B(5).
D. The data field j cannot be accessed by object b.

Leave a Comment