Bird
Raised Fist0

When a client calls a method on a Proxy object that controls access to a resource-intensive service, what is the typical sequence of events that occurs internally?

easy🧠🧾 Concept Trace Q12 of Q15
OOP & Design Patterns - Adapter vs Facade vs Proxy - Structural Pattern Comparison
When a client calls a method on a Proxy object that controls access to a resource-intensive service, what is the typical sequence of events that occurs internally?
AProxy performs access control, then lazily initializes the real service if needed, and finally forwards the call
BProxy immediately forwards the call to the real service without any checks
CProxy modifies the request parameters before forwarding to the real service
DProxy creates a simplified interface hiding the complexity of the real service
Step-by-Step Solution
  1. Step 1: Understand Proxy's role

    Proxy controls access and may delay creation of the real service (lazy initialization).
  2. Step 2: Trace the call flow

    Client calls Proxy -> Proxy checks access -> Proxy creates real service if not already created -> Proxy forwards call -> Real service executes.
  3. Step 3: Eliminate incorrect options

    B is incorrect because Proxy usually adds control logic before forwarding. C is incorrect as Proxy typically does not modify parameters (that's Decorator or Adapter). D describes Facade, not Proxy.
  4. Final Answer:

    Option A -> Option A
Quick Trick: Proxy = gatekeeper + lazy loader
Common Mistakes:
MISTAKES
  • Assuming Proxy always forwards calls immediately without checks
  • Confusing Proxy with Facade's simplification role
  • Thinking Proxy modifies request parameters
Trap Explanation:
PITFALL
  • Proxy adds control and lazy initialization, not just forwarding or interface simplification.
Interviewer Note:
CONTEXT
  • Tests understanding of Proxy's internal control flow and lazy initialization behavior.
Master "Adapter vs Facade vs Proxy - Structural Pattern Comparison" in OOP & Design Patterns

2 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More OOP & Design Patterns Quizzes