menu

Python OOPs Concepts


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

static

def

classmethod

None of the above


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


3. Which of the following is true about instance variables in Python?

They are defined inside the class but outside any method

They are shared by all instances of a class

They are accessed using the class name

None of the above


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

dot notation

square bracket notation

parentheses notation

curly brace notation


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

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

It is used to check if an object is an instance of any class

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

None of the above


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


7. What is encapsulation in Python?

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

The process of exposing the implementation details of a class to its users

The process of creating a new class from an existing class

None of the above


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


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

self

new

create

None of the above


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