CS FundamentalsHardProduct company interview · GATE level
A rendering engine has a Shape hierarchy (Circle, Square) and a separate Renderer hierarchy (VectorRenderer, RasterRenderer), and any Shape can be drawn with any Renderer by holding a reference to one, avoiding a combinatorial class explosion like CircleVectorRenderer, SquareRasterRenderer, etc. Which pattern is this?
- A. Abstract Factory
- B. Bridge
- C. Adapter
- D. Composite
Correct answer: B. Bridge
Bridge decouples an abstraction (Shape) from its implementation (Renderer) so both hierarchies can vary independently, avoiding the class explosion of one subclass per abstraction-implementation combination. Adapter instead makes one existing interface compatible with another, not a planned independent-variation design.
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 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 /…
- In a class diagram, Student has an association to Course with multiplicity 0.. on the Student side and 0.. on the Course side…