CS FundamentalsHardWipro · Accenture pattern
A spreadsheet's Cell objects can contain other Cells (a range), and client code calls cell.getValue() uniformly whether cell is a single number cell or a range of cells, with the range summing its children recursively. Which pattern is this?
- A. Bridge
- B. Flyweight
- C. Composite
- D. Decorator
Correct answer: C. Composite
Composite lets clients treat individual objects and compositions of objects (a tree of parts and wholes) uniformly through a shared interface — exactly the single-cell-vs-range-of-cells scenario. Decorator adds behaviour to a single object; it doesn't model part-whole trees.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- A rendering engine has a Shape hierarchy (Circle, Square) and a separate Renderer hierarchy (VectorRenderer, RasterRenderer), and any…
- A text editor needs to support thousands of on-screen Character objects efficiently. Most of a Character's data (font, size, color) is…
- A rule says: a loan is approved only if (credit score >= 700) AND (income >= 50000) AND (no existing default). Using a decision table that…
- A password field must be 8–20 characters long. Using boundary value analysis on this single range, which set of test lengths is the…
- A use case diagram shows a base use case 'Place Order' with an arrow labelled <<extend>> pointing from 'Apply Discount Code' to 'Place…
- A state machine diagram for an Order has states New, Paid and Shipped, with a transition from New to Paid labelled 'payment confirmed /…