Examveda

What will be the output of the following Python code?
class student:
    def __init__(self):
        self.marks = 97
        self.__cgpa = 8.7
    def display(self):
        print(self.marks)
obj=student()
print(obj._student__cgpa)

A. The program runs fine and 8.7 is printed

B. Error because private class members can't be accessed

C. Error because the proper syntax for name mangling hasn't been implemented

D. The program runs fine but nothing is printed

Answer: Option A


Join The Discussion

Related Questions on Concept of Object Oriented Programs in Python