File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Mock Exam question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Mock Exam question" Watch "Mock Exam question" New topic

Mock Exam question

shyam paleti

Joined: Apr 30, 2010
Posts: 2
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.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11778

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.

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
I agree. Here's the link:
subject: Mock Exam question
It's not a secret anymore!