Adv - Java Means Durga Sir: Plot No: 202, Iind Floor, Huda Maitrivanam, Ameerpet, Hyd-5000038
Adv - Java Means Durga Sir: Plot No: 202, Iind Floor, Huda Maitrivanam, Ameerpet, Hyd-5000038
Page 1
Plot No : 202, IInd Floor ,HUDA Maitrivanam,Ameerpet, Hyd-5000038.
www.durgasoft.com
ADV.JAVA Means DURGA SIR
Unit-6: Java EE Patterns
Objectives
1.Given a scenario description with a list of issues, select a pattern that would
solve the issues. The list of patterns you must know are: Intercepting Filter,
Model-View-Controller, Front Controller, Service Locator, Business Delegate,
and Transfer Object.
Q1. Squeaky Beans Inc. hired an outside consultant to develop their web
application. To finish the job quickly, the consultant created several dozen JSP
pages that directly communicate with the database. The Squeaky business team has
since purchased a set of business objects to model their system, and the Squeaky
developer charged with maintaining the web application must now refactor all the
JSPs to work with the new system. Which pattern can the developer use to solve this
problem?
A. Transfer Object
B. Service Locator
C. Intercepting Filter
D. Business Delegate
Answer: D
Q2. A developer is designing a web application that must verify for each
request:The originating request is from a trusted network.
The client has a valid session.
The client has been authenticated.
A. Transfer Object
B. Session Facade
C. Intercepting Filter
D. Template Method
E. Model-View-Controller
Answer: C
Page 2
Plot No : 202, IInd Floor ,HUDA Maitrivanam,Ameerpet, Hyd-5000038.
www.durgasoft.com
ADV.JAVA Means DURGA SIR
Q3. The Squeaky Bean company has decided to port their web application to a new
J2EE 1.4 container. While reviewing the application, a developer realizes that in
multiple places within the current application, nearly duplicate code exists that finds
enterprise beans. Which pattern should be used to eliminate this duplicate code?
Answer: C
Q4. Which two are characteristics of the Transfer Object design pattern? (Choose
two.)
Answer: A, C
Page 3
Plot No : 202, IInd Floor ,HUDA Maitrivanam,Ameerpet, Hyd-5000038.
www.durgasoft.com
ADV.JAVA Means DURGA SIR
Q5. developer has created a special servlet that is responsible for generating XML
content that is sent to a data warehousing subsystem. This subsystem uses HTTP to
request these large data files, which are compressed by the servlet to save internal
network bandwidth. The developer has received a request from management to
create several more of these data warehousing servlets. The developer is about to
copy and paste the compression code into each new servlet. Which design pattern
can consolidate this compression code to be used by all of the data warehousing
servlets?
Answer: D
Q6. Which two are characteristics of the Service Locator pattern? (Choose two.)
A. It encapsulates component lookup procedures.
B. It increases source code duplication and decreases reuse.
C. It improves client performance by caching context and factory objects.
D. It degrades network performance due to increased access to distributed lookup
services.
Answer: A, C
Q7. The Squeaky Bean company has decided to port their web application to a new
J2EE 1.4 container. While reviewing the application, a developer realizes that in
multiple places within the current application, nearly duplicate code exists that finds
enterprise beans. Which pattern should be used to eliminate this duplicate code?
Page 4
Plot No : 202, IInd Floor ,HUDA Maitrivanam,Ameerpet, Hyd-5000038.
www.durgasoft.com
ADV.JAVA Means DURGA SIR
Q8. A developer is designing a web application that makes many fine-grained
remote data requests for each client request. During testing, the developer discovers
that the volume of remote requests significantly degrades performance of the
application. Which design pattern provides a solution for this problem?
Q9. In an n-tier application, which two invocations are typically remote, not local?
(Choose two.)
Answer: B, D
Q10. A developer has created a special servlet that is responsible for generating
XML content that is sent to a data warehousing subsystem. This subsystem uses
HTTP to request these large data files, which are compressed by the servlet to save
internal network bandwidth. The developer has received a request from
management to create several more of these data warehousing servlets. The
developer is about to copy and paste the compression code into each new servlet.
Which design pattern can consolidate this compression code to be used by all of the
data warehousing servlets?
A. Facade
B. View Helper
C. Transfer Object
D. Intercepting Filter
E. Composite Facade
Answer: D
Page 5
Plot No : 202, IInd Floor ,HUDA Maitrivanam,Ameerpet, Hyd-5000038.
www.durgasoft.com
ADV.JAVA Means DURGA SIR
Q11. A developer is designing the presentation tier for a web application which
requires a centralized request handling to complete common processing required by
each request. Which design pattern provides a solution to this problem?
A. Remote Proxy B. Front Controller
C. Service Activator D. Intercepting Filter
E. Business Delegate F. Data Access Object
Answer: B
Q12. You are designing an n-tier Java EE application. You have already decided
that some of your JSPs will need to get data from a Customer entity bean. You are
trying to decide whether to use a Customer stub object or a Transfer Object. Which
two statements are true? (Choose two.)
Q13. You are designing an n-tier Java EE application. You have already decided
that some of your JSPs will need to get data from a Customer entity bean. You are
trying to decide whether to use a Customer stub object or a Transfer Object. Which
two statements are true? (Choose two.)
A. The stub will increase network traffic.
B. The Transfer Object will decrease data staleness.
C. The stub will increase the logic necessary in the JSPs.
D. In both cases, the JSPs can use EL expressions to get data.
E. Only the Transfer Object will need to use a Business Delegate.
F. Using the stub approach allows you to design the application without using a Service
Locator.
Answer: A, D
Page 6
Plot No : 202, IInd Floor ,HUDA Maitrivanam,Ameerpet, Hyd-5000038.
www.durgasoft.com
ADV.JAVA Means DURGA SIR
Q14. Which two are characteristics of the Intercepting Filter pattern? (Choose two.)
A. It provides centralized request handling for incoming requests.
B. It forces resource authentication to be distributed across web components.
C. It reduces coupling between presentation-tier clients and underlying business
services.
D. It can be added and removed unobtrusively, without requiring changes to existing
code.
E. It allows preprocessing and postprocessing on the incoming requests and outgoing
responses.
Answer: D, E
Q15. A developer has created a web application that includes a servlet for each use
case in the application. These servlets have become rather difficult to maintain
because the request processing methods have become very large. There is also
common processing code in many servlets because these use cases are very similar.
Which two design patterns can be used together to refactor and simplify this web
application? (Choose two.)
Page 7
Plot No : 202, IInd Floor ,HUDA Maitrivanam,Ameerpet, Hyd-5000038.
www.durgasoft.com
ADV.JAVA Means DURGA SIR
Q18.developer is designing a web application which extensively uses EJBs and JMS.
The developer finds that there is a lot of duplicated code to build the JNDI contexts
to access the beans and queues. Further, because of the complexity, there are
numerous errors in the code.
Which J2EE design pattern provides a solution for this problem?
A. Command B. Transfer Object
C. Service Locator D. Session Facade
E. Business Delegate F. Data Access Object
Answer: C
Q19. Which two are characteristics of the Front Controller pattern? (Choose two.)
A. It simplifies remote interfaces to distributed objects.
B. It promotes cleaner application partitioning and encourages reuse.
C. It provides an initial point of contact for handling all related requests.
D. It reduces maintainability due to the increased complexity of the design.
E. It provides loosely coupled handlers that can be combined in various permutations.
Answer: B, C
Q20. Squeaky Beans Inc. hired an outside consultant to develop their web
application. To finish the job quickly, the consultant created several dozen JSP
pages that directly communicate with the database. The Squeaky business team has
since purchased a set of business objects to model their system, and the Squeaky
developer charged with maintaining the web application must now refactor all the
JSPs to work with the new system. Which pattern can the developer use to solve this
problem?
Answer: D
Page 8
Plot No : 202, IInd Floor ,HUDA Maitrivanam,Ameerpet, Hyd-5000038.
www.durgasoft.com
ADV.JAVA Means DURGA SIR
Q 21. A developer is designing the presentation tier for a web application that relies
on a complex session bean. The session bean is still being developed and the APIs for
it are NOT finalized. Any changes to the session bean API directly impacts the
development of the presentation tier.
Which design pattern provides a means to manage the uncertainty in the API?
A. View Helper
B. Front Controller
C. Composite View
D. Intercepting Filter
E. Business Delegate
F. Chain of Responsibility
Answer: E
Answer: C, D
Answer: C
Page 9
Plot No : 202, IInd Floor ,HUDA Maitrivanam,Ameerpet, Hyd-5000038.
www.durgasoft.com
ADV.JAVA Means DURGA SIR
Page 10
Plot No : 202, IInd Floor ,HUDA Maitrivanam,Ameerpet, Hyd-5000038.
www.durgasoft.com