menu

Python OOPs Concepts


1. Which of the following is a decorator in Python?

@classmethod

@staticmethod

@property

All of the above


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

def

class

method

function


3. Which method is used to convert an object to a string in Python?

str

init

repr

new


4. Which of the following is true about abstract classes in Python?

An abstract class cannot be instantiated

An abstract class must contain at least one abstract method

An abstract class can be inherited by another class

All of the above


5. Which of the following is true about the super() function in Python?

It is used to call a method in the parent class

It is used to call a method in the current class

It is used to call a method in a child class

None of the above


6. What is polymorphism in object-oriented programming?

The ability of an object to take on many forms

The process of defining two methods with the same name in a class

The process of defining a variable in a class

The process of calling methods from other classes


7. Which method is used to access the representation of an object in Python?

str

repr

eq

cmp


8. Which method is used to compare two objects in Python?

cmp

eq

lt

gt


9. Which of the following is true about multiple inheritance in Python?

A class can inherit from multiple classes at the same time

A class can inherit from only one class at a time

Multiple inheritance is not supported in Python

None of the above


10. Which method is called when an object is hashed in Python?

hash

cmp

eq

ne