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
1. What is the purpose of the __init__ method in a Python class?
- To destroy the object
- To initialize the object
- To represent the class as string
- To compare two objects
3. What does "self" represent in a class method?
- The class itself
- The parent class
- The current object instance
- A static method
4. Which method is called when an object is created?
- __del__
- __init__
- __str__
- __main__
5. What is inheritance in Python classes?
- Creating multiple objects
- Hiding implementation details
- Inheriting properties from parent class
- Importing modules
6. How do you call a parent class method from a child class?
- parent()
- super()
- base()
- self.parent()
7. What is method overriding in Python?
- Creating multiple methods with same name
- Hiding a method from parent class
- Providing new implementation in child class
- Deleting a parent method
8. What is encapsulation in OOP?
- Hiding implementation details
- Inheriting from multiple classes
- Bundling data and methods together
- Creating abstract classes
9. How do you create a private variable in Python?
- Using private keyword
- Prefix with single underscore
- Prefix with double underscores
- Using var keyword
10. What is polymorphism in Python?
- Multiple inheritance
- Same method behaving differently for different objects
- Method overloading
- Data hiding