Objects Questions and Answers
Practice ModeShowing 10 of 25 questions
Q11
What does the __del__ method do?
Answer: Option B
Explanation: The __del__ method is called when an object is about to be destroyed.
Q12
What is method overriding in Python?
Answer: Option B
Explanation: Method overriding allows a subclass to provide a specific implementation of a method that is already defined in its parent class.
Q13
How do you make a method private in Python?
Answer: Option B
Explanation: Private methods are indicated by prefixing the method name with double underscores.
Q14
What is the super() function used for?
Answer: Option B
Explanation: The super() function is used to call methods from the parent class.
Q15
What are properties in Python classes?
Answer: Option B
Explanation: Properties allow you to use getter and setter methods while accessing them like regular attributes.
Q16
What is multiple inheritance in Python?
Answer: Option B
Explanation: Multiple inheritance allows a class to inherit from more than one parent class.
Q17
What is the Method Resolution Order (MRO) in Python?
Answer: Option B
Explanation: MRO determines the order in which base classes are searched when looking for a method.
Q18
What is the difference between __str__ and __repr__?
Answer: Option B
Explanation: __str__ is for end-user representation, while __repr__ is for developer representation and should be unambiguous.
Q19
What are class methods in Python?
Answer: Option B
Explanation: Class methods are bound to the class rather than instances and can modify class state.
Q20
What are static methods in Python?
Answer: Option B
Explanation: Static methods don't have access to the class or instance and behave like regular functions but belong to the class namespace.