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.
- A. The process by which objects communicate with one another by invoking each other's methods.
Why not A: “The process by which objects communicate with one another by invoking each other's methods.” is not correct. 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 use
- B. A design principle in which a class is built using instances of other classes as components, forming a 'has-a' relationship. ✓
- C. The practice of restricting direct access to an object's internal data to protect it from unintended interference.
Why not C: “The practice of restricting direct access to an object's internal data to protect it from unintended interference.” is not correct. 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 use
- D. A special method automatically invoked when an object is destroyed, used to release resources.
Why not D: “A special method automatically invoked when an object is destroyed, used to release resources.” is not correct. 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 use
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
- Which statement correctly explains Access modifier?
- Select the accurate description of Association.
- Select the correct name for: a keyword that controls the visibility and accessibility of a class's members, su...
- Which term refers to a mechanism where the method to be executed is determined at runtime rather than at compi...
- In computer science, Static member refers to which of the following?
- What does Dynamic binding refer to?