QuizzesMultiton Pattern — Concept Check
intermediate
lld

Multiton Pattern — Concept Check

Questions on Multiton Pattern. Extends Singleton by maintaining a registry of named instances, ensuring one instance per key rather than one instance globally.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on Multiton Pattern — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.You are designing a logging system where each class should have its own logger instance. Which pattern would be most suitable for this requirement?

    • ASingleton pattern
    • BFactory pattern
    • CPrototype pattern
    • DMultiton pattern
  2. 2.In a multithreaded application, you need to ensure a single database connection pool per tenant. How can you achieve this?

    • AUse a Multiton with tenant ID as the key
    • BCreate a new pool for each request
    • CUse a Singleton for all tenants
    • DShare a global pool across all tenants
  3. 3.A developer uses `ConcurrentHashMap.putIfAbsent()` instead of `computeIfAbsent()` in a Multiton. What issue might arise?

    • AIncreased memory usage
    • BThread safety issues
    • CInability to store null values
    • DUnnecessary instantiation of values
  4. 4.Which of the following is a benefit of using an EnumMap in a Multiton pattern?

    • AFaster access for enum keys
    • BAutomatic synchronization
    • CReduced memory usage
    • DSupport for dynamic keys
  5. 5.You notice that two different tenants are sharing the same database connection pool. What could be the cause?

    • AIncorrect key usage in the Multiton
    • BInsufficient pool size
    • CNetwork latency issues
    • DUsing Singleton instead of Multiton
  6. 6.Why might a developer choose `computeIfAbsent()` over `putIfAbsent()` in a Multiton implementation?

    • ATo allow null values
    • BTo avoid unnecessary instantiation
    • CFor better memory management
    • DTo simplify code readability
  7. 7.In a system using a Multiton pattern, you observe that every call to `getInstance()` for the same key returns a different object. What might be wrong?

    • AThe Multiton is incorrectly implemented
    • BThe factory function is not deterministic
    • CThe ConcurrentHashMap is not thread-safe
    • DThe key is being modified