menu

Python OOPs Concepts


1. Which keyword is used to create a new instance of a class in Python?

self

new

create

None of the above


2. What is the purpose of a destructor in Python?

To free up resources when an object is destroyed

To create a new object

To define variables in a class

To call methods from other classes


3. Which method is called when an object is used as a string in Python?

str

repr

cmp

hash


4. Which of the following is true about the init method in Python?

It is called when an object is created from a class

It is called when an object is deleted

It is used to define instance variables

None of the above


5. Which keyword is used to define a static method in Python?

static

def

classmethod

None of the above


6. Which method is called when an object is compared to another object in Python?

eq

cmp

ne

lt


7. Which of the following is true about the issubclass() function in Python?

It is used to check if a class is a subclass of another class

It is used to check if an object is an instance of a specific class

It is used to check if a class is an instance of another class

None of the above


8. Which keyword is used to define a class in Python?

class

def

method

function


9. Which keyword is used to define an instance variable in Python?

class

self

instance

var


10. What is polymorphism in Python?

The ability of an object to take on many forms

The process of creating a new class from an existing class

The process of hiding the implementation details of a class from its users

None of the above