ITPEC FE Subject A October 2024 Question 36

Which of the following is an appropriate description of “delegation” in object orientation?

Explanation

An object has another object perform the operation — delegation forwards a request instead of handling it itself.

With delegation, an object that receives a request does not implement the operation itself; it holds a reference to another object and passes the request on to it. This reuses the other object's behavior through composition rather than inheritance, and the delegate can be swapped at run time.

Answer (d)

Why not others:

  • •(a) — building one new object out of several objects as its parts is aggregation (composition)
  • •(b) — a lower-level class taking over the attributes and operations of a higher-level class is inheritance
  • •(c) — an operation on one object being applied automatically to related objects is propagation

Key rule: Delegation reuses behavior by forwarding requests to an object it has ("has-a"); inheritance reuses it by being a subclass ("is-a").

System Development Technology · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.