CS FundamentalsHardProduct-company MCQ pattern
A text editor needs to support thousands of on-screen Character objects efficiently. Most of a Character's data (font, size, color) is shared across many characters with the same formatting, while only position differs per character. Which pattern reduces memory by sharing the common, immutable formatting data across instances?
- A. Flyweight
- B. Prototype
- C. Singleton
- D. Proxy
Correct answer: A. Flyweight
Flyweight separates intrinsic (shared, immutable) state like font/size/color from extrinsic (per-instance) state like position, storing shared state once and referencing it from many lightweight objects — exactly the massive-character-count memory optimisation described.
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 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 /…
- In a class diagram, Student has an association to Course with multiplicity 0.. on the Student side and 0.. on the Course side…
- An activity diagram shows a fork bar splitting one flow into two concurrent activities (ValidateAddress and ChargeCard), which later…