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


3.

What is the syntax to create a new instance of a class in Python?

object = ClassName()

object = new ClassName()

object = create ClassName()

object = instance ClassName()


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

self

new

create

None of the above


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


6. What is the purpose of encapsulation in object-oriented programming?

To hide implementation details

To define variables in a class

To create new objects

To call methods from other classes


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


8. Which of the following is true about class variables in Python?

They are defined inside a method

They are shared by all instances of a class

They are accessed using the instance name

None of the above


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

cmp

eq

lt

gt


10. Which keyword is used to refer to the current object in a class method in Python?

self

this

me

current