Skip to content

Object-Oriented Programming (OOP)

What is Composition primarily used for?

Difficulty: Hard

About this MCQ

This Hard Object-Oriented Programming (OOP) MCQ checks one syllabus fact.

The question is: “What is Composition primarily used for?”

The accepted answer is B. A design principle in which a class is built using instances of other classes as components, forming a 'has-a' relationship.. A design principle in which a class is built using instances of other classes as components forming a 'has-a' relationship is the fact required by What is Composition primarily used for option B Option A The process by which objects communicate with one another by invoking each other's methods does not match the stem it is a near-miss used to catch incomplete recall of A design principle in which a class is built using instances of other classes as components forming a 'has-a' relationship Option C The practice of restricting direct access to an object's internal data to protect it from unintended interference does not match the stem it is a near-miss used to catch incomplete recall of A design.

Correct answer

B. A design principle in which a class is built using instances of other classes as components, forming a 'has-a' relationship.

Explanation

A design principle in which a class is built using instances of other classes as components forming a 'has-a' relationship is the fact required by What is Composition primarily used for option B Option A The process by which objects communicate with one another by invoking each other's methods does not match the stem it is a near-miss used to catch incomplete recall of A design principle in which a class is built using instances of other classes as components forming a 'has-a' relationship Option C The practice of restricting direct access to an object's internal data to protect it from unintended interference does not match the stem it is a near-miss used to catch incomplete recall of A design.

Source: Object-Oriented Programming (OOP) Official Reference Guide

Tags: computer science, oop, object-oriented programming, software design

Submitted by: MCQsHub Editorial

Related MCQs

More Object-Oriented Programming (OOP) MCQs