Examveda

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

D. The program has an error because display() can't be accessed

Answer: Option C


Join The Discussion

Related Questions on Concept of Object Oriented Programs in Python