Python OOPs Concepts
Python OOPs Concepts - Important Points
16. | Which method is used to delete an object in Python? |
---|
A. del
B. delete
C. remove
D. destroy
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The method "del" is used to delete an object in Python.
17. | Which keyword is used to define a static method in Python? |
---|
A. static
B. def
C. classmethod
D. None of the above
View Answer Discuss Work SpaceAnswer: option d
Explanation:
None of the above keywords are used to define a static method in Python. The @staticmethod decorator is used instead.
18. | What is the purpose of a class method in Python? |
---|
A. To create new objects
B. To call methods from other classes
C. To define variables in a class
D. To perform actions on a class itself
View Answer Discuss Work SpaceAnswer: option d
Explanation:
The purpose of a class method in Python is to perform actions on a class itself.
19. | Which keyword is used to define an instance variable in Python? |
---|
A. class
B. self
C. instance
D. var
View Answer Discuss Work SpaceAnswer: option b
Explanation:
The keyword "self" is used to define an instance variable in Python.
20. | Which method is used to access the representation of an object in Python? |
---|
A. str
B. repr
C. eq
D. cmp
View Answer Discuss Work SpaceAnswer: option b
Explanation:
The method "repr" is used to access the representation of an object in Python.