0% found this document useful (0 votes)
247 views

A Presentation Tier Component Is Requesting Data Attributes

A presentation tier component is requesting data attributes scattered across multiple business components, DAOs, and services. The Transfer Object Assembler pattern is best suited to provide the client with the required data without significant performance degradation by assembling the scattered data into transfer objects.

Uploaded by

Prince Jain
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
247 views

A Presentation Tier Component Is Requesting Data Attributes

A presentation tier component is requesting data attributes scattered across multiple business components, DAOs, and services. The Transfer Object Assembler pattern is best suited to provide the client with the required data without significant performance degradation by assembling the scattered data into transfer objects.

Uploaded by

Prince Jain
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 24

A presentation tier component is requesting data attributes, which are scattered in multiple

business components, DAOs and services in your application?

Which pattern is best suited for this scenario, providing the client with the required data causing
no significant performance degradation?

No. Answers Correct You selected


1 Business Object
2 Transfer Object Assembler
3 Data Acess Object
4 Composite Entitiy

When is it recommended to use a Value List Handler Pattern?

You
No. Answers Correct
selected
1 You want to avoid embedding business logic in the view
You want to avoid passing protocol-specific information outside its
2
context
You want to provide the clients with an efficient search and iterate
3
mechanism over a large results set
4 You want to maintain the search results on the client side

Your online shop application maintains the customers information, like their personal
information,contact lists and lists of purchases.

The remote descktop clients usually require only parts of these information. Which pattern
would be most appropriate for this scenario and would improve your system?

No. Answers Correct You selected


1 Updatable Transfer Objects
2 Transfer Object Assembler
3 Entity Inherits Transfer Object
4 Multiple Transfer Objects Strategy
You application's performance is affected due to repeated JNDI lookups done by every client
accessing your application.
Which pattern is most appropriate to improve the performance and solve the problem?

No. Answers Correct You selected


1 Service Locator
2 Session Facade
3 Business Delegate
4 Transfer Object

A service locator is best implemented as a Singleton.

No. Answers Correct You selected


1 true
2 false

Your application's performance is affected due to the significant number of remote calls to your
business logic. The business logic is exposed as fine grained methods to the clients.

Which refactoring can be done to improve the application's performance? (choose two)

(choose 2)

You
No. Answers Correct
selected
1 Add a Front Controller to centralize requests processing
Implement a Session Facade, which provides a coarse grained
service-oriented interface
2
to clients
3 Move the frequently called business logic to the presentation tier
Encapsulate multiple business data attributes into smaller set of
4
serializable transfer objects, to reduce remote invocations

ABC university library system is available to students over different campuses in the world and
installed in one server in the main campus. Queries results are usually large result sets returned
all to clients which causes a heavy load on both client and server.
What do you think can be done to alleviate this problem on a tight budget?

You
No. Answers Correct
selected
Place a server in each campus to serve the students in this campus
to
1
distribute the load
2 apply Transfer Object Pattern
3 apply a Value List Handler Pattern

What is TRUE about the Updatable Transfer Objects Strategy? (choose 3)

You
No. Answers Correct
selected
It is used when the client needs not only to read the business
component attributes
1
but also to be able to modify them
It reduces the complexity of the system in terms of update
2
propagation and synchronization
It adds on complexity to the system in terms of update propagation
3
and synchronization
4 Transfer Objects in general can reduce network overhead

Integration Tier J2EE Patterns


Which integration pattern can be used to integrate Java EE code to a relational database?

No. Answers Correct You selected


1 Service Activator
2 Front Controller
3 Data Access Object (DAO)
4 Web Service Broker

What pattern is applied in Java Message Driven Beans?

No. Answers Correct You selected


1 Service Locator
2 Service Activator
3 Service to Worker
4 Front Controller

You want to expose part of your application as services to other client applications. The client
application will request a service through standard web protocols. The requests are received by a
servlet which in turn delegetes them to the bussiness tier.

Which pattern is most appropriate for this task?

No. Answers Correct You selected


1 Service Activator
2 Service Locator
3 Web Service Broker
4 Service to Worker

What is the role of a Service Activator?

You
No. Answers Correct
selected
1 A Service Activator acts as a centralized point to process http
You
No. Answers Correct
selected
requests
A Service Activator allows an asynchronous messages to invoke
2
business components, including the EJBs
A Service Activator enables business logic in EJBs to be exposed
3
as web services

What benefits does Data Access Object (DAO) pattern provide? (choose two) (choose 2)

You
No. Answers Correct
selected
it increases the cohesiveness of the business objects by extracting
1
out the data acess code from them
2 it reduces network overhead by caching queries results
it enhances loose coupling between the business tier and the data
3
sources

Presentation Tier----------------

How to secure you web application against security risks such as cross site scripting (css) and
SQL injection in a centralized manner that avoids code duplicate and ensures that every HTTP
request would be inspected? (choose 2)

No. Answers Correct You selected


1 use Intercepting Filter pattern
No. Answers Correct You selected
2 use Front Controller pattern
3 use Composite View pattern
4 use Business Delegate pattern

Which of the following patterns would you use to transfer certain state to the next tier without
passing on protocol-specific system information?

No. Answers Correct You selected


1 Transfer Object
2 Context Object
3 Context Filter
4 Service To Worker

Your job is to refactor an application ,which uses JSP technology as a View. The JSP pages are
dominated by scriptlet code.

Which pattern would be appropriate to solve this problem?

No. Answers Correct You selected


1 View Helper
2 Composite View
3 Data Access Object
4 Context Object

In your web application you decided to use Javascript to validate each user input on the client
browser.

Where do you need to duplicate the validation code on the server?

You
No. Answers Correct
selected
No double check on the server side is needed as the input is already
1
checked on the client side
You
No. Answers Correct
selected
2 double check in the presentation tier
3 double check in the integration tier
4 double check in the business tier
Explanation:

You always need to double check the user input as it not guaranteed that user is actually using
the intended interface as you planned.

You would like to raise the security level of your system by examining incoming HTTP
requests. You would like to log information about each request and to filter requests with
malicious scripts.

Where would you put such request processing code?

No. Answers Correct You selected


1 in the Service Locator
2 in the Service Activator
3 in the Intercepting Filter
4 in the View Helper

Your Parcel delivery company is expanding it's existing web application.

Currently the clients can track their parcels using web browsers, and your company wants to
expose it's business to it's partners as web-services.

However; when you inspected the code base, you discovered that the application passes
HttpServletRequest parameters to the business tier for further processing.

Your job is to refactor this existing code base to avoid duplicating the business logic to handle
the two request channels (http and web service requests).

Which refactoring is appropriate for this case without code duplication?


No. Answers Correct You selected
1 Use front controller pattern
2 Use context object pattern
3 Use proxy pattern
4 Use service broker pattern

you are in charge of developing an e-commerce web application, the client expects high traffic
volumes and the security is of essence.

Which user session management strategy would you choose?

No. Answers Correct You selected


1 Save user session in http cookies
2 Save user session in html hidden fields
3 Save user session in an HttpSession object
4 Save user session in an EJB stateful session bean object

A pattern that is intended to provide a means to define a family of algorithms and encapsulate
each one as an object for interchangeable use:

No. Answers Correct You selected


1 Strategy Pattern
2 Abstract Factory Pattern
3 Visitor Pattern
4 State Pattern

It is known as Action or Transaction and is used to encapsulate a request as an object to support


rollback, logging, or transaction functionality

No. Answers Correct You selected


1 Chain of Responsibility Pattern
2 Command Pattern
No. Answers Correct You selected
3 Observer Pattern
4 Strategy Pattern

Which is considered an example of Chain of Responsibility Pattern? (choose two) (choose 2)

No. Answers Correct You selected


1 java.awt.event.ComponentAdapter
2 The Java Servlet filter framework
3 javax.jms.QueueConnectionFactory
4 java.awt.Toolkit
5 Java exception handling

Which are considered forces to select a Strategy Pattern? (choose two) (choose 2)

No. Answers Correct You selected


1 A client needs to use a family of related objects
2 A change to an object requires changing other objects
3 A client needs to choose from multiple algorithms
4 Multiple classes are the same but differ only in their behaviors

java.util.Enumeration is an example of which pattern?

No. Answers Correct You selected


1 Iterator
2 Command
3 Observer
4 Strategy

In the Publish-Subscribe messaging model, the subscribers register themselves in a topic and are
notified when new messages arrive to the topic. Which pattern does most describe this model?

No. Answers Correct You selected


1 Adapter
2 Notifier
No. Answers Correct You selected
3 Observer
4 State
Explanation:

The Observer pattern is used to define a one-to-many dependency so that when one object
changes state, all its dependents are notified and updated automatically.

This definition is perfectly describe Publish-Subscribe model, actually the Observer pattern is
also known as Publish-Subscribe.

Which pattern to use when more than one object can handle a request, and the handler is
unknown?

No. Answers Correct You selected


1 Chain of Responsibility
2 Command
3 Strategy
4 Observer

Which pattern is most appropriate when a decision must be made at the time a class is
instantiated?

No. Answers Correct You selected


1 Bridge
2 Composite
No. Answers Correct You selected
3 Factory Method
4 Command
Explanation:

Creational Design Patterns are used when a decision must be made at the time a class is
instantiated.

GoF Creational Design Patterns are :

1. Abstract Factory

2. Builder

3. Factory Method

4. Prototype

5. Singleton

Which design pattern is used in the Java Database connectivity JDBC(TM)?

No. Answers Correct You selected


1 Builder design pattern
2 Factory method design pattern
3 Abstract Factory design Pattern
4 Singletone design Pattern

Which GOF design pattern is applied in the code snippet below?


view source
print?
01.public class PrintSpooler {
02.
03.private static final PrintSpooler INSTANCE = new PrintSpooler();
04.
05.private PrintSpooler() {}
06.
07.public static PrintSpooler getInstance() {
08.
09.return INSTANCE;
10.
11.}
12.
13.}

No. Answers Correct You selected


1 PrintSpooler design pattern
2 Spooler design pattern
3 Singleton design pattern
4 Factory design pattern
5 Abstract Singleton design pattern

Which of the following are participants in the GOF builder design pattern? (choose 3)

No. Answers Correct You selected


1 Builder interface
2 Constructor Interface
3 Director Interface
4 Concrete Builder class
5 Concrete constructor class

When would you use the GOF Singleton design pattern? (choose all that apply) (choose 2)

No. Answers Correct You selected


1 to ensure that a certain group of related objects are used together
2 to limit the class instantiation to one object
3 to provide global access to once instance across the system
4 to abstract steps of construction of complex objects

Which design pattern you would you use to limit the class instantiation to one object?

No. Answers Correct You selected


1 Factory Method Design Pattern
2 Builder design pattern
3 Prototype design pattern
4 Singleton design pattern
What are the consequences of applying the abstract factory patter? (choose 2)

No. Answers Correct You selected


1 it will be much easier to introduce new family of products
2 it makes it easier for a certain family of objects to work together
3 it makes it easier for the client to deal with tree-structured data
4 it makes the designed product families exchangeable

When would you use the GOF builder design pattern? (choose all that apply) (choose 2)

You
No. Answers Correct
selected
1 to abstract steps of construction of complex objects
to build different representations of complex objects based on the
2
concrete implementations of construction procedure
to establish an interface for creating an object, but let the concrete
3
implementations decide which subclass to instantiate
to encapsulate a family of individual factories that have a common
4
theme

Given the following scenario:

You want to create families of related objects, to be used interchangeably to configure you
application. What is the most appropriate GoF pattern to use?

No. Answers Correct You selected


1 Chain of Responsibility
2 Abstract Factory
3 Builder
4 Observer

Which design pattern you would you use to control the creation of an object based on a
established interface, while allowing the concrete implementation to determine the subclass to
construct.

No. Answers Correct You selected


1 Singleton design pattern
No. Answers Correct You selected
2 Builder Factory design pattern
3 Prototype factory design pattern
4 Factory method design pattern

What are the consequences of applying the Builder design pattern? (choose 3)

No. Answers Correct You selected


1 it makes the designed product hierarchies exchangeable
2 it's easier to introduce new product implementation
3 it separates the prodcut construction from it's representation
4 the director has fine control over the product creation procedure

What are the consequences of applying the GOF Singleton pattern? (choose 1)

You
No. Answers Correct
selected
it introduces thread safety issue when the singleton instance is
1
instantiated on demand
2 the client code can creates multiple instances at run time
it reduces of the class hierarchy as compared to the other factory
3
design patterns
4 it makes it easier for a certain family of objects to work together
Which design pattern you would you use to have a prototypical instance determine the concrete
class of object being created?

No. Answers Correct You selected


1 Prototype factory design pattern
2 Virtual prototype design pattern
3 Abstract prototype design pattern
4 Prototype design pattern

Which of the following code snippet represents a Singleton design pattern implementation?

No. Answers CorrectYou selected


1 public class PrintSpooler {
No. Answers CorrectYou selected

public PrintSpooler INSTANCE = new PrintSpooler();

public PrintSpooler () {}

public static PrintSpooler getInstance() {

return INSTANCE;

}
public class PrintSpooler {

private PrintSpooler INSTANCE = new PrintSpooler();

private PrintSpooler () {}

2 public static PrintSpooler getInstance() {

return INSTANCE;

}
public class PrintSpooler {

private static final PrintSpooler INSTANCE = new PrintSpooler();

private PrintSpooler () {}

3 public static PrintSpooler getInstance() {

return INSTANCE;

}
4 public class PrintSpooler {

private final PrintSpooler INSTANCE = new PrintSpooler();

private PrintSpooler () {}
No. Answers CorrectYou selected

public static PrintSpooler getInstance() {

return INSTANCE;

What are the consequences of applying the GOF Prototype pattern? (choose 3)

You
No. Answers Correct
selected
1 each concrete prototype class must implement the clone method
2 it makes it easier for a certain family of objects to work together
it enable the client code to register an new concrete prototype
3
instance at run time
it reduces of the class hierarchy as compared to the other factory
4
design patterns

What are the consequences of applying the GOF factory method pattern? (choose 2)

You
No. Answers Correct
selected
1 it decouples the client code from the application specific classes
2 it makes the designed product families exchangeable
it establishes a flexible mechanism for instantiating an object in
3
comparison to the usual java constructor instantiation.

What are the consequences of applying the GOF Composite pattern? (choose 2)

You
No. Answers Correct
selected
1 the client code can traverse tree structures of arbitrary depth
You
No. Answers Correct
selected
recursively
increases the coupling between the client code and the composite
2
structre
3 it will improve the system performance
the client code can access both the individual objects and
4
compositions in a uniform manner

A pattern known as Surrogate is :

No. Answers Correct You selected


1 Adapter
2 Proxy
3 Facade
4 Method Factory

What are the consequences of applying the GOF Decorator pattern? (choose 3)

You
No. Answers Correct
selected
the client code can gradually add more functionality as it nests more
1
layers of decorators
2 it assigns more functionality to an object without sub-classing it
it makes it harder to identify the the decorated and the decorator
3
objects
the client code can traverse tree structures of arbitrary depth
4
recursively

You are trying to add a class already written in another application to serve clients, beside other
classes, in your system. All other classes have the same interface, the incoming class has a
totally different interface than the clients expect, but contains all required functionalities.

What kind of refactoring is needed to make this class fit in with minimum changes in your
system?
You
No. Answers Correct
selected
1 apply the Proxy Pattern
2 apply the Adapter Pattern
create a new class which implements the expected interface and
copy and paste
3
the code from the class in the other application to this new class
Explanation:

The Adapter pattern converts the interface of a class into an interface that a client expects.

Which design pattern is used in the Java InputStream, OutputStream, Reader, Writer hierarchies?

No. Answers Correct You selected


1 Adapter design pattern
2 Decorator design pattern
3 Composite design pattern
4 Bridge design pattern
Which design pattern is used in the Java AWT Abstract Window Toolkit?

No. Answers Correct You selected


1 Adapter design pattern
2 Composite design pattern
3 Bridge design pattern
4 Proxy design pattern

What is the difference between an adapter and a decorator? (choose two) (choose 2)

You
No. Answers Correct
selected
The adapter adds no functionalities to the adaptee class, whereas the
Decorator
1
extends the functionality of the object
The adapter is a creational pattern, whereas the decorator is a
2
structural design pattern
Both introduce a level of indirection between a client class and a
3
class it uses
Explanation:
Both the adapter and the decorator are structural design patterns

Big portion of clients are remotely invoking methods in your system, the surface area exposed
to clients includes fine-grained methods, which of course causes network overhead.

Which pattern would improve your system performance in this case?

No. Answers Correct You selected


1 Chain of Responsibility Pattern
2 Facade Pattern
3 Command Pattern
4 Adapter Pattern
Explanation:

Facade pattern provides a simpler interface to a complex subsystem. This way a coarse-grained
methods are available to clients instead of fine-grained ones, this way the network overhead is
reduced, thus performance if improved.

You are building an online makeup website, which provides beside text articles, makeup
tutorials as videos files.

Which pattern is recommended to use in such a website to deliver these media resources?

No. Answers Correct You selected


1 value list handler
2 virtual proxy
3 intercepting filter
4 composite view

Which design pattern you would you use to decouple an abstraction from its implementation so
that the two can vary independently?
No. Answers Correct You selected
1 Adapter design pattern
2 bridge design pattern
3 Facade design pattern
4 Composite bridge design pattern

Which design pattern you would you use to translates an existing class interface into a
compatible target interface?

No. Answers Correct You selected


1 Proxy design pattern
2 Adapter design pattern
3 Facade design pattern
4 Adapter factory design pattern
Which design pattern you would you use to assign more functionality to an object without sub-
classing it?

No. Answers Correct You selected


1 Bridge design pattern
2 Adapter design pattern
3 Composite design pattern
4 Decorator design pattern

It is also known as Wrapper, it is used when subclassing is not possible or practical to add
functionality and it is used to add functionality at runtime. This pattern is :

No. Answers Correct You selected


1 Composite
2 Adapter
3 Decorator
4 Proxy

A Proxy Pattern is best used to : (choose three) (choose 3)

You
No. Answers Correct
selected
1 control access to a remote object
You
No. Answers Correct
selected
2 assemble complex objects
3 fetch a resource-intensive object when requested by a client
4 store common redundant data between large number of objects
extract out from the calling client the access or connection logic
5
needed to call an object

Which of the following is a Gang of Four (GoF) Structural Design Pattern? (choose 2)

No. Answers Correct You selected


1 Composite
2 Flyweight
3 Singleton
4 Method Factory
Explanation:

Composite and Flyweight are Gang of Four (GoF) Structural Design Patterns, whereas Singleton
and Method Factory are Creational Design Patterns

When would you use the GOF Adapter design pattern? (choose all that apply) (choose 3)

You
No. Answers Correct
selected
to translates an existing class interface into a compatible target
1
interface
2 to improve your system performance
to transforming the client code data into appropriate format
3
expected by the target interface
4 to allow classes with incompatible interfaces to work together
In EJB 2.x, the client can directly access the session bean by invoking their business methods:

No. Answers Correct You selected


1 true
2 false
Explanation:

Clients cannot access session beans directly. To gain access to

session bean methods, they use instances of EJBObject . Therefore any method, in the session
bean, designated to be available to clients, must be added to the EJBObject of the bean.

Message Driven Beans (MDBs) can be pooled by the EJB container.

No. Answers Correct You selected


1 true
2 false
Explanation:

Like the stateless session beans and the entity beans, message driven beans can be pooled by the
EJB container

What services EJB containers provide to Session beans? (choose 3)


No. Answers Correct You selected
1 Caching and pooling
2 EJB life cycle management
3 HTTP requests management
4 RMI services

What is the default transaction attribute to a method in an EJB? (no explicit transaction attribute
is declared in both class and method levels)

No. Answers Correct You selected


1 NotSupported
2 Required
3 Supports
4 Mandatory
5 Never

What is the typical order of life cycle stages an average stateless session bean goes through
starting from its instantiation till retiring?

You
No. Answers Correct
selected
Instantiation by the EJB container, PostConstruct call back,
1
Dependency injection, PrePassivate
Instantiation by the EJB container, PostConstruct call back,
2
Dependency injection, PreDestroy
Instantiation by the client code, Dependency injection,
3
PostConstruct call back, PreDestroy
Instantiation by the EJB container, Dependency injection,
4
PostConstruct call back, PreDestroy

Which of the following transactional settings would throw an exception when calling a method
while the presence of an already existing transaction context?

No. Answers Correct You selected


1 NotSupported
2 Required
3 Supports
4 RequiresNew
5 Mandatory
No. Answers Correct You selected
6 Never

Message Driven Beans (MDBs) are designed to function as :

No. Answers Correct You selected


1 Synchronous message publisher
2 Synchronous message consumer
3 Asynchronous message publisher
4 Asynchronous message consumer

What are the requirements of a message-driven bean (EJB 2.x) class? (choose 3)

No. Answers Correct You selected


1 It implements the MessageListener interfaces
2 It implements onMessage() method
3 It implements receive() method
4 It is configured as a MDB in the deployment descriptor

Message Driven Beans (MDBs) can be directly accessed by internal or external clients.

No. Answers Correct You selected


1 true
2 false

You might also like