Classes Questions and Answers
Python Programming - Classes Questions with Answers introduce learners to object-oriented principles like encapsulation and data modeling. These Python Classes Questions are key for Wipro, TCS, SSC, and RRB exams to understand how to create and use classes effectively
Classes
Showing 10 of
25 questions
11. What is the difference between class and instance variables?
- No difference
- Class variables are per instance, instance variables are shared
- Class variables are shared, instance variables are per object
- Both are the same
12. How do you create a static method in Python?
- @staticmethod decorator
- static keyword
- def static()
- Using static method
13. What is a class method in Python?
- Method that only works with instances
- Method that takes cls parameter and works with class
- Method that cannot access class variables
- Method that is private to class
14. What is the purpose of the __str__ method?
- String conversion of object
- Object destruction
- Object comparison
- Object creation
15. What is multiple inheritance in Python?
- One class inheriting from one parent
- One class inheriting from multiple parents
- Multiple classes inheriting from one parent
- No inheritance
16. What is an abstract class in Python?
- Class that can be instantiated directly
- Class with no methods
- Class that cannot be instantiated and requires method implementation
- Class with only variables
17. How do you create a property in Python?
- Using property keyword
- @property decorator
- def property()
- create_property()
18. What is method overloading in Python?
- Creating multiple methods with same name but different parameters
- Only one method per class
- Method that overloads memory
- Inheriting methods
19. What is the MRO (Method Resolution Order) in Python?
- Method return order
- Method resolution order for inheritance
- Memory read order
- Module load order
20. What is a destructor method in Python?
- __init__
- __del__
- __destroy__
- __cleanup__