在线名词解释大全 - Python程序设计 - 详细

15()Analyzethefollowingcode:classA:def__init__(self):self.x=1self.__y=1defgetY(self):returnself.__ya=A()a.__y=45print(a.getX())

A
The program has an error because x is private and cannot be access outside of the class.
B
The program has an error because y is private and cannot be access outside of the class.
C
The program has an error because you cannot name a variable using __y.
D
The program runs fine and prints 1.
E
The program runs fine and prints 45.
正确答案:
相关推荐
扫描二维码
关注公众平台