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?

  1. A. Abstract Factory
  2. B. Bridge
  3. C. Adapter
  4. 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.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic