Classes Questions and Answers

Take Exam

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
Show Answer Report

2. Which keyword is used to create a class in Python?

  • class
  • def
  • struct
  • object
Show Answer Report

3. What does "self" represent in a class method?

  • The class itself
  • The parent class
  • The current object instance
  • A static method
Show Answer Report

4. Which method is called when an object is created?

  • __del__
  • __init__
  • __str__
  • __main__
Show Answer Report

5. What is inheritance in Python classes?

  • Creating multiple objects
  • Hiding implementation details
  • Inheriting properties from parent class
  • Importing modules
Show Answer Report

6. How do you call a parent class method from a child class?

  • parent()
  • super()
  • base()
  • self.parent()
Show Answer Report

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
Show Answer Report

8. What is encapsulation in OOP?

  • Hiding implementation details
  • Inheriting from multiple classes
  • Bundling data and methods together
  • Creating abstract classes
Show Answer Report

9. How do you create a private variable in Python?

  • Using private keyword
  • Prefix with single underscore
  • Prefix with double underscores
  • Using var keyword
Show Answer Report

10. What is polymorphism in Python?

  • Multiple inheritance
  • Same method behaving differently for different objects
  • Method overloading
  • Data hiding
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test