• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Mock Exam question

Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For me it appears either AbstractFactory/factoryMethod to be correct answer. But Singleton is given as answer. Can anybody explain.
Below is the question:

You are creating a web application for an online product ordering system. You will be using data from several different databases and to reduce the load on the databases you have decided to use connection pooling. You have a ConnectionPool class and you want one pool for each database however you will have to connect to a variable number of databases. What pattern should you use?

A Abstract factory
B Factory Method
C Builder
D Prototype
E Singleton

Choice E is correct.

The Singleton doesn't just create a single instance it can also be used to create a variable number of instances of a class.The Abstract factory pattern is used for creating many objects that are dependent on each other so choice A is incorrect. The Factory Method pattern provides an interface for creating an object defers creation to either sub classes or helper classes. Hence choice B is incorrect. The Builder pattern separates the construction and representation of an object. The client is shielded from the objects construction only needing to specify it's content and type. Choice C is hence incorrect. The Prototype pattern is used to create new objects by copying its prototype. Choice D is therefore incorrect.
author and jackaroo
Posts: 12200
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reminder: If you don't mention the copyright holder (which mock exam is this), we will assume you are breaching copyright laws and start with deleting the message.
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic