Question 422 of 513
1Z0-829 Utilizing Java Object-Oriented Approach Practice Question
You are designing a logging framework for a microservices application. The framework must support multiple output destinations (console, file, database) and allow new destinations to be added without modifying existing code. Additionally, each destination should be able to format the log message differently. The team prefers composition over inheritance. Which design pattern should you recommend?
⚠ Common exam trap
Oracle often tests the distinction between structural patterns (Decorator) and behavioral patterns (Observer), and the trap here is that candidates confuse 'adding destinations' with 'wrapping objects,' leading them to incorrectly choose the Decorator pattern despite its unsuitability for managing multiple independent observers.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Observer pattern where the logger is the subject and each output destination is an observer. Formatting can be handled by each observer using a separate strategy.
The Observer pattern is correct because it decouples the logger (subject) from multiple output destinations (observers), allowing new destinations to be added without modifying existing code. Each observer can independently apply its own formatting logic, which aligns with the composition-over-inheritance principle and the requirement for per-destination formatting. This pattern directly supports the dynamic addition of observers at runtime, fulfilling the extensibility goal.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Observer pattern where the logger is the subject and each output destination is an observer. Formatting can be handled by each observer using a separate strategy.
Why this is correct
Observers can be added/removed dynamically, and each observer can use a Strategy for formatting, adhering to composition.
- ✗
Template Method pattern where the logger defines the skeleton of logging, and subclasses override formatting and output steps.
Why it's wrong here
Template Method uses inheritance, not composition, and adding a new destination requires creating a new subclass.
- ✗
Decorator pattern to wrap log messages with formatting, and add destinations by nesting decorators.
Why it's wrong here
Decorator adds responsibilities to individual objects, but adding a new destination would require changing the decorator chain, not ideal.
- ✗
Factory Method pattern to create log messages, and each destination implements a different factory.
Why it's wrong here
Factory Method deals with object creation, not with notification of log events.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Last reviewed: Jun 30, 2026
This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.