1. Home
  2. Data Science
  3. Python
  4. What is composition in OOP in Python?

Added 25 Nov 2026

What is composition in OOP in Python?

  1. Inheriting from multiple classes
  2. Building classes by including other objects as attributes Correct answer
  3. Hiding methods
  4. Overriding methods

Correct answer

B. Building classes by including other objects as attributes

5 views

MCQSEXAM

Explanation

Composition models a has-a relationship and is often preferred over inheritance.

Reference

Asked in: Python Interview OOP

https://docs.python.org/3/tutorial/classes.html

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs