Classes Questions and Answers
Practice ModeShowing 10 of 25 questions
Q21
How do you check if an object is an instance of a class?
Answer: Option B
Explanation: The isinstance() function checks if an object is an instance of a class or its subclasses.
Q22
What is the purpose of the __call__ method?
Answer: Option B
Explanation: The __call__ method allows an instance to be called as a function.
Q23
What are dunder methods in Python?
Answer: Option C
Explanation: Dunder methods (double underscore) are special methods that start and end with double underscores.
Q24
What is composition in OOP?
Answer: Option B
Explanation: Composition is creating complex objects by combining simpler objects, rather than inheriting from them.
Q25
What is the difference between is and == in Python?
Answer: Option B
Explanation: "is" checks identity (same object), "==" checks equality (same value).