Object Pool Pattern — Concept Check
Questions on Object Pool Pattern. Manages a set of reusable, pre-initialized objects to avoid the overhead of repeated creation and destruction of expensive resources.
Questions in this quiz
8 questions on Object Pool Pattern — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A service using an object pool is experiencing delays when borrowing objects. What could be a likely cause?
- AThe pool size is larger than necessary.
- BObjects are not being validated before borrowing.
- CThe pool is exhausted and objects are being created on demand.
- DThe pool has too many idle objects.
2.In an object pool, what happens if the returned object is not valid?
- AThe object is destroyed and not returned to the pool.
- BThe pool throws an exception.
- CThe object is returned to the pool regardless.
- DThe object is repaired and returned to the pool.
3.You notice your application is using a custom connection pool instead of HikariCP. What is a potential downside?
- ACustom pools require less configuration.
- BCustom pools may lack advanced tuning features.
- CCustom pools automatically scale beyond max size.
- DCustom pools are always faster than HikariCP.
4.A developer claims that object pools always prevent resource leaks. What is a flaw in this belief?
- APools eliminate the need for validation.
- BPools never reach their maximum size.
- CImproperly returned objects can still cause leaks.
- DPools automatically manage all resources.
5.In the provided Java object pool implementation, what happens if the pool is full when returning an object?
- AThe pool expands to accommodate the object.
- BThe object is destroyed.
- CThe object is kept in a temporary list.
- DThe object is added to the pool anyway.
6.Why might a JDBC connection pool like HikariCP be preferred over a custom implementation?
- AIt requires no configuration.
- BIt offers built-in performance optimizations.
- CIt always uses fewer resources.
- DIt prevents all connection errors.
7.What does the 'maxWait' parameter in an object pool configuration specify?
- AMaximum time to keep an object before destroying it.
- BMaximum time to wait for an object before creating a new one.
- CMaximum time an object can be idle in the pool.
- DMaximum number of objects in the pool.
8.In the context of object pools, what is the purpose of the 'validation query'?
- ATo initialize objects when created.
- BTo ensure objects are still usable before lending.
- CTo destroy objects that are no longer needed.
- DTo increase the pool size dynamically.