Objects Questions and Answers
Python Programming - Objects Questions with Answers explain how real-world entities are represented in code. These Python Objects Questions are essential for Infosys, Accenture, SSC CGL, and Banking exams to understand the use of attributes and methods in classes effectively
Objects
Showing 10 of
25 questions
11. What does the __del__ method do?
- Deletes a class
- Destructor - called when object is destroyed
- Deletes a variable
- Delays object creation
12. What is method overriding in Python?
- Creating multiple methods with same name in same class
- Redefining a parent class method in child class
- Hiding methods from other classes
- Converting methods to properties
13. How do you make a method private in Python?
- Using private keyword
- Prefix with double underscores
- Using @private decorator
- Prefix with single underscore
14. What is the super() function used for?
- To create super classes
- To call parent class methods
- To make classes faster
- To override multiple methods
15. What are properties in Python classes?
- Variables that can only be read
- Attributes with getter/setter methods
- Methods that return values
- Class-level constants
16. What is multiple inheritance in Python?
- A class with multiple methods
- A class inheriting from multiple parents
- Multiple instances of same class
- A class with multiple constructors
17. What is the Method Resolution Order (MRO) in Python?
- Order of method execution
- Order in which base classes are searched for methods
- Order of method parameters
- Order of object destruction
18. What is the difference between __str__ and __repr__?
- No difference, they are the same
- __str__ for users, __repr__ for developers
- __str__ is faster than __repr__
- __repr__ is only for numbers
19. What are class methods in Python?
- Methods that only work with class variables
- Methods bound to the class, not instance
- Methods that cannot be overridden
- Methods that are automatically called
20. What are static methods in Python?
- Methods that cannot be changed
- Methods that don't take self or cls
- Methods that are fastest
- Methods that only work with instances