Vidyalelo
Python · Q62

Concept of Object Oriented Programs in Python

Programming · Python · question 62

Q62

What will be the output of the following Python code? class fruits: def __init__(self): self.price = 100 self.__bags = 5 def display(self): print(self.__bags) obj=fruits() obj.display()

A.
The program has an error because display() is trying to print a private class member
B.
The program runs fine but nothing is printed
C.
The program runs fine and 5 is printed
Answer
D.
The program has an error because display() can't be accessed

Answer: Option C

Solution

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