Vidyalelo
Python · Q79

Concept of Object Oriented Programs in Python

Programming · Python · question 79

Q79

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
Answer
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

Solution

Answer: Option A
No explanation is given for this question Let's Discuss on Board