Python OOPs Concepts
Python OOPs Concepts - Important Points
26. | Which keyword is used to make a class variable private in Python? |
---|
A. public
B. protected
C. private
D. None of the above
View Answer Discuss Work SpaceAnswer: option c
Explanation:
The keyword "private" is used to make a class variable private in Python.
27. | Which method is called when an object is used as a string in Python? |
---|
A. str
B. repr
C. cmp
D. hash
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The method "str" is called when an object is used as a string in Python.
28. | Which method is called when an object is hashed in Python? |
---|
A. hash
B. cmp
C. eq
D. ne
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The method "hash" is called when an object is hashed in Python.
29. | What is polymorphism in Python? |
---|
A. The ability of an object to take on many forms
B. The process of creating a new class from an existing class
C. The process of hiding the implementation details of a class from its users
D. None of the above
View Answer Discuss Work SpaceAnswer: option a
Explanation:
Polymorphism in Python is the ability of an object to take on many forms.
30. | Which method is called when an object is used as a key in a dictionary in Python? |
---|
A. hash
B. eq
C. cmp
D. None of the above
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The method "hash" is called when an object is used as a key in a dictionary in Python.