menu

Python OOPs Concepts


1. What is a constructor in Python?

A special method that is automatically called when an object is created

A method that is used to define a new object

A method that is used to create a new instance of a class

A method that is used to convert an object to a string


2. What is method overriding in Python?

The process of defining a new method in a subclass with the same name as a method in the parent class

The process of deleting a method in a subclass

The process of creating a new method in a subclass with a different name than a method in the parent class

None of the above


3. Which of the following is true about method overriding in Python?

It occurs when a subclass provides a different implementation for a method that is already defined in the parent class

It occurs when a subclass adds a new method to the parent class

It occurs when a subclass inherits all the methods from the parent class

None of the above


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

@classmethod

@staticmethod

@property

All of the above


5. 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


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

str

repr

eq

cmp


7. Which method is used to access an attribute in a class in Python?

dot notation

square bracket notation

parentheses notation

curly brace notation


8. What is the purpose of a class method in Python?

To create new objects

To call methods from other classes

To define variables in a class

To perform actions on a class itself


9. What is inheritance in Python?

The process of creating a new class from an existing class

The process of deleting a class

The process of creating an object from a class

None of the above


10. 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