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
1. What is an object in Python?
- A blueprint for creating instances
- An instance of a class
- A built-in function in Python
- A module containing multiple functions
2. Which method is called when an object is created in Python?
- __init__
- __new__
- __create__
- __start__
3. What is the purpose of the "self" parameter in Python class methods?
- It refers to the class itself
- It refers to the current object instance
- It is a reference to the parent class
- It indicates a static method
4. Which of the following is an example of encapsulation in Python objects?
- Using inheritance to create subclasses
- Using private variables with double underscores
- Overloading operators
- Using multiple inheritance
5. How do you create a class in Python?
- class MyClass:
- def MyClass():
- new class MyClass:
- create class MyClass:
6. What is inheritance in Python?
- Creating multiple instances of a class
- A class deriving properties from another class
- Hiding implementation details
- Converting one data type to another
7. Which method is used to represent an object as a string?
- __repr__
- __str__
- __string__
- __format__
8. What is polymorphism in Python?
- Creating multiple classes with same name
- Ability to take many forms
- Hiding complex implementation
- Converting objects to strings
9. How do you create an instance of a class in Python?
- new MyClass()
- MyClass.create()
- MyClass()
- create MyClass
10. What is the difference between class variables and instance variables?
- Class variables are immutable, instance variables are mutable
- Class variables are shared, instance variables are per object
- Class variables can only be strings
- Instance variables are defined outside the class