Classes Questions and Answers

Practice Mode
Showing 10 of 25 questions
Q21
How do you check if an object is an instance of a class?
  • A type()
  • B isinstance()
  • C checkinstance()
  • D obj.type()
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?
  • A Object creation
  • B Making object callable like function
  • C Object comparison
  • D Object destruction
Answer: Option B
Explanation: The __call__ method allows an instance to be called as a function.
Q23
What are dunder methods in Python?
  • A Regular methods
  • B Private methods only
  • C Special methods with double underscores
  • D Imported methods
Answer: Option C
Explanation: Dunder methods (double underscore) are special methods that start and end with double underscores.
Q24
What is composition in OOP?
  • A Inheritance only
  • B Building objects using other objects
  • C Method overloading
  • D Data hiding
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?
  • A No difference
  • B is checks identity, == checks value
  • C is checks value, == checks identity
  • D Both check identity
Answer: Option B
Explanation: "is" checks identity (same object), "==" checks equality (same value).
Questions and Answers for Competitive Exams Various Entrance Test