menu

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

Discuss Work Space

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

Discuss Work Space

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

Discuss Work Space

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

Discuss Work Space

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

Discuss Work Space

Answer: option a

Explanation:

The method "hash" is called when an object is used as a key in a dictionary in Python.


Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now