Python OOPs Concepts
Python OOPs Concepts - Important Points
11. | Which method is used to compare two objects in Python? |
---|
A. cmp
B. eq
C. lt
D. gt
View Answer Discuss Work SpaceAnswer: option b
Explanation:
The method "eq" is used to compare two objects in Python.
12. | Which keyword is used to define a class in Python? |
---|
A. class
B. def
C. method
D. function
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The keyword "class" is used to define a class in Python.
13. | What is the purpose of a destructor in Python? |
---|
A. To free up resources when an object is destroyed
B. To create a new object
C. To define variables in a class
D. To call methods from other classes
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The purpose of a destructor in Python is to free up resources when an object is destroyed.
14. | Which method is used to access an attribute in a class in Python? |
---|
A. dot notation
B. square bracket notation
C. parentheses notation
D. curly brace notation
View Answer Discuss Work SpaceAnswer: option a
Explanation:
The dot notation is used to access an attribute in a class in Python.
15. | Which keyword is used to create a new instance of a class in Python? |
---|
A. self
B. new
C. create
D. None of the above
View Answer Discuss Work SpaceAnswer: option d
Explanation:
None of the above keywords are used to create a new instance of a class in Python. The correct syntax is ClassName().