menu

Python OOPs Concepts

Python OOPs Concepts - Important Points


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

A. To hide implementation details

B. To define variables in a class

C. To create new objects

D. To call methods from other classes

Discuss Work Space

Answer: option a

Explanation:

The purpose of encapsulation in object-oriented programming is to hide implementation details.

7. Which method is automatically called when an object is created in Python?

A. new

B. init

C. str

D. repr

Discuss Work Space

Answer: option b

Explanation:

The method "init" is automatically called when an object is created in Python.

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

A. str

B. init

C. repr

D. new

Discuss Work Space

Answer: option a

Explanation:

The method "str" is used to convert an object to a string in Python.

9. What is a constructor in Python?

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

B. A method that is used to define a new object

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

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

Discuss Work Space

Answer: option a

Explanation:

A constructor is a special method that is automatically called when an object is created.

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

A. self

B. this

C. me

D. current

Discuss Work Space

Answer: option a

Explanation:

The keyword "self" is used to refer to the current object in a class method in Python.


Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now