Saturday 23 March 2013

OCMJEA Practice Guide - Free Sample Chapter 6 - Web Technologies


Book Link: Amazon USA Link
Web Tier Technologies

Questions

OBJECTIVE: State benefits and drawbacks of adopting a web framework in designing a Java EE application.

Q1. Which of the following are benefits of adopting a web framework?
Answer choices: (Select 2)
A.   Automate session management
B.   Enables UI templating
C.   Disable code reuse
D.   Disable security

Q2. Which of the following are drawbacks of using a web framework?
Answer choices: (Select 2)
A.   Skills upgrade may be at a cost
B.   Choosing between many choices is difficult
C.   Performance is better
D.   Clear direction to choose a framework

Q3. You have to support both mobile phones and browser clients in the application being developed. Which technology would you choose?
Answer choices: (Select best answer)
A.   JSP
B.   JSP with EL
C.   JSF
D.   JSP with JSTL

Q4. You have to access the existing inventory system using web services. Which type of architecture will you suggest?
Answer choices: (Select best answer)
A.   JSP with stateless session beans
B.   JSF with stateless session beans
C.   JSF with JAX-WS
D.   JSF with JMS

Q5. You have an existing application written using an earlier version of JEE platform. The client wishes to improve the maintainability of the application. Which strategy would you suggest?
Answer choices: (Select best answer)
A.   Rewrite using JSF, EJB and JPA
B.   Rewrite using JSP, EJB and JPA
C.   Apply best practices on existing application
D.   Rewrite using JSF, JMS, EJB and JPA

OBJECTIVE: Explain standard uses for JSP pages and servlets in a typical Java EE application.

Q1. You are thinking of recommending Java Server Pages as the presentation tier technology. Which of the following key features would you recommend?
Answer choices: (Select 3)
A.   Template content
B.   Static content
C.   Ability to extend tags
D.   Scripting elements

Q2. You are convincing the client that JSP technology can be hosted on any platform, run on any web server or a Java EE application server and accessed from any web browser. Which benefit of JSP is being talked about?
Answer choices: (Select best answer)
A.   Tool support
B.   Write once, run anywhere
C.   Tag library reuse
D.   Separation of web developer and web designer roles

Q3. You want to emphasize on the use of JSP technology as the choice of presentation tier technology. Which of the following benefits will you highlight?
Answer choices: (Select 3)
A.   Support for expressions, scripting and actions
B.   Always the choice for front-end technology
C.   Separation of dynamic and static content
D.   Reuse of components and tag libraries

Q4. You are making a note of the available options when a JSP page is compiled. Which of the following options will you note?
Answer choices: (Select 2)
A.   On first request
B.   On every request
C.   At deployment time
D.   During server startup

Q5. You are in a meeting where discussion is based on the use of tag libraries. Which of the following points will you make?
Answer choices: (Select 3)
A.   Custom actions
B.   Static content
C.   Listener classes
D.   Validation

Q6. Which of the following technologies are competitive technologies of Java Servlet technology?
Answer choices: (Select 3)
A.   CGI
B.   JSP
C.   Netscape Server API
D.   Apache Modules

Q7. Which of the following Servlet lifecycle methods are executed once?
Answer choices: (Select 2)
A.   init
B.   service
C.   destroy
D.   doGet

Q8. Your application design requires a pool of servlet instances. Which interface should you inherit to force this property?
Answer choices: (Select best answer)
A.   SingleThreadModel
B.   MultipleThreadModel
C.   No interface
D.   SingleProcessModel

Q9. Which of the following are exceptions thrown by a Servlet?
Answer choices: (Select 2)
A.   ServletException
B.   UnavailableException
C.   ServletUnavailableException
D.   ServletError

Q10. Which of the following are session tracking mechanisms?
Answer choices: (Select best answer)
A.   Cookies
B.   URL rewriting
C.   HTTPSession
D.   Form fields

OBJECTIVE: Explain standard uses for JavaServer Faces components in a typical Java EE application.

Q1. You are discussing the key features of JSF with your team. Which points will you highlight?
Answer choices: (Select 3)
A.   Reuse existing UI components
B.   Manages UI state across requests
C.   Custom UI components difficult to build
D.   Easy development of custom UI components

Q2. You are negotiating with the client about the challenges associated with the web applications and how JSF addresses those challenges. Which points will you discuss?
Answer choices: (Select 3)
A.   Support form processing
B.   Validation
C.   No event model
D.   Error handling
Q3. You are discussing the roles that a JSF developer plays. Which of the following roles are valid?
Answer choices: (Select 3)
A.   Page author
B.   Application architect
C.   Component writer
D.   Tool provider

Q4. Which of the following are different scenarios that occur in a JSF application?
Answer choices: (Select 3)
A.   Non-faces request generates faces response
B.   Faces request generates faces response
C.   Faces request generates non-faces response
D.   Non-faces request generates non-faces response

Q5. Which phase of JSF life cycle builds the view of the page, wires event handlers and validators?
Answer choices: (Select best answer)

A.   Restore view
B.   Apply request values
C.   Invoke application
D.   Render response

Q6. Which phase of JSF life cycle uses the decode method to extract new value from the request parameters?
Answer choices: (Select best answer)
A.   Restore view
B.   Apply request values
C.   Invoke application
D.   Render response

Q7. Which phase of JSF life cycle processes all validators registered in the component tree?
Answer choices: (Select best answer)
A.   Restore view
B.   Apply request values
C.   Process validations
D.   Render response

Q8. Which phase of JSF life cycle walks the component tree and sets the corresponding server-side properties to local value?
Answer choices: (Select best answer)
A.   Update model values
B.   Apply request values
C.   Process validations
D.   Render response

Q9. Which phase of JSF life cycle handles application-level events?
Answer choices: (Select best answer)
A.   Update model values
B.   Invoke applications
C.   Process validations
D.   Render response

Q10. Which phase of JSF life cycle renders the page?
Answer choices: (Select best answer)
A.   Update model values
B.   Invoke applications
C.   Process validations
D.   Render response

OBJECTIVE: Given a system requirements definition, explain and justify your rationale for choosing a web-centric or EJB-centric implementation to solve the requirements. Web-centric means that you are providing a solution that does not use EJB components. EJB-centric solution will require an application server that supports EJB components.

Q1. A large retail customer has a requirement for a complex transaction processing system with existing system integration. As an architect, what would you recommend?
Answer choices: (Select best answer)
A.   EJB-centric system with no external system
B.   Web-centric system with external system
C.   EJB-centric system with external system
D.   Web-centric system with no external system

Q2. You are the architect of a small B2C website where ease of development is the primary concern. Which type of architecture would you recommend?
Answer choices: (Select best answer)
A.   EJB-centric system with no external system
B.   Web-centric system with external system
C.   EJB-centric system with external system
D.   Web-centric system with no external system

Q3. A banking system requires role based security for the mortgage website. Which type of architecture would you recommend?
Answer choices: (Select best answer)
A.   EJB-centric system with no external system
B.   Web-centric system with external system
C.   EJB-centric system with external system
D.   Web-centric system with no external system

Q4. The development team does not have EJB skills. The website you are developing requires integration with an inventory system. Which type of architecture would you recommend?
Answer choices: (Select best answer)
A.   EJB-centric system with no external system
B.   Web-centric system with external system
C.   EJB-centric system with external system
D.   Web-centric system with no external system

Q5. A back office system is required to update the details in a banking system. Which type of architecture would you recommend?
Answer choices: (Select best answer)
A.   EJB-centric system with no external system
B.   Web-centric system with external system
C.   EJB-centric system with external system
D.   Web-centric system with no external system



Answers


OBJECTIVE: State benefits and drawbacks of adopting a web framework in designing a Java EE application.

Q1. Which of the following are benefits of adopting a web framework?
Answer choices: (Select 2)
A.   Automate session management
B.   Enables UI templating
C.   Disable code reuse
D.   Disable security
Correct Answer: A and B
Explanation: Web frameworks help in implementing features such as action handlers, validators, transactions, security, automate session management and enables UI templates. It does promote code reuse and does not disable security. Hence options A and B are correct, and C and D are incorrect.

Q2. Which of the following are drawbacks of using a web framework?
Answer choices: (Select 2)
A.   Skills upgrade may be at a cost
B.   Choosing between many choices is difficult
C.   Performance is better
D.   Clear direction to choose a framework
Correct Answer: A and B
Explanation: The drawbacks of adopting a web framework include costly skill upgrade. Hence choosing between several web frameworks is difficult. There is a performance overhead and there is no clear direction in choosing a web framework. Sometimes a web framework may be overkill, and it may not be required. Hence options A and B are correct, and C and D are incorrect.

Q 3. You have to support both mobile phones and browser clients in the application being developed. Which technology would you choose?
Answer choices: (Select best answer)
A.   JSP
B.   JSP with EL
C.   JSF
D.   JSP with JSTL
Correct Answer: C
Explanation: A JSF-based architecture is preferred because the renderers support both mobile devices and browser clients. Hence option C is correct. The other options are invalid.

Q 4.  You have to access the existing inventory system using web services. Which type of architecture will you suggest?
Answer choices: (Select best answer)
A.   JSP with stateless session beans
B.   JSF with stateless session beans
C.   JSF with JAX-WS
D.   JSF with JMS
Correct Answer: C
Explanation: A stateless session bean may not be required in the current context and JMS may not be required to access the web services. The best answer is option C, which uses JSF with JAX-WS technology to access the web service. The other options are incorrect. 

Q5. You have an existing application written using an earlier version of JEE platform. The client wishes to improve the maintainability of the application. Which strategy would you suggest?
Answer choices: (Select best answer)
A.   Rewrite using JSF, EJB and JPA
B.   Rewrite using JSP, EJB and JPA
C.   Apply best practices on existing application
D.   Rewrite using JSF, JMS, EJB and JPA
Correct Answer: C
Explanation: Since the client wishes to improve the maintainability of the application, the best practices should be applied and the application needs to be re-factored. The other options for rewrite may not be a suitable choice considering the cost and effort. Hence option C is correct, and the other options are incorrect.  

OBJECTIVE: Explain standard uses for JSP pages and servlets in a typical Java EE application.

Q1. You are thinking of recommending Java Server pages as the presentation tier technology. Which of the following key features would you recommend?
Answer choices: (Select 3)
A.   Template content
B.   Static content
C.   Ability to extend tags
D.   Scripting elements
Correct Answer: A, C and D
Explanation: JSP key features include standard directives and actions, scripting elements, template content and ability to extend tag support. For static content, you may not use a dynamic technology like JSP. Hence options A, C and D are correct and option B is incorrect.

Q2. You are convincing the client that JSP technology can be hosted on any platform, run on any web server or a Java EE application server and accessed from any web browser. Which benefit of JSP is being talked about?
Answer choices: (Select best answer)
A.   Tool support
B.   Write once, run anywhere
C.   Tag library reuse
D.   Separation of web developer and web designer roles
Correct Answer: B
Explanation: Write once, run anywhere feature of Java is applied to JSP technology as well because components can be written on any platform, run on any Java EE server and accessed from any browser. Hence option B is correct. The other choices are benefits of JSP but not relevant to the question.

Q3. You want to emphasize on the use of JSP technology as the choice of presentation tier technology. Which of the following benefits will you highlight?
Answer choices: (Select 3)
A.   Support for expressions, scripting and actions
B.   Always the choice for front-end technology
C.   Separation of dynamic and static content
D.   Reuse of components and tag libraries
Correct Answer: A, C and D
Explanation: JSP benefits include support for expressions, scripting and actions. It lets you separate dynamic and static content. Also, one can reuse components and tag libraries speeding up development effort. Hence options A, C and D are correct. JSP technology is not always the choice for front-end technology making option B incorrect.

Q4. You are making a note of the available options when a JSP page is compiled. Which of the following options will you note?
Answer choices: (Select 2)
A.   On first request
B.   On every request
C.   At deployment time
D.   During server startup
Correct Answer: A and C
Explanation: JSP pages are compiled during deployment or when a first request arrives. Hence options A and C are correct. JSP page is not compiled on every request or during server startup making options B and D incorrect.

Q5. You are in a meeting where discussion is based on the use of tag libraries. Which of the following points will you make?
Answer choices: (Select 3)
A.   Custom actions
B.   Static content
C.   Listener classes
D.   Validation
Correct Answer: A, C and D
Explanation: Tag libraries deliver custom actions, listener classes and validation. Static content may not be provided by tag libraries. Hence options A, C and D are correct, and B is incorrect.

Q6. Which of the following technologies are competitive technologies of Java Servlet technology?
Answer choices: (Select 3)
A.   CGI
B.   JSP
C.   Netscape Server API
D.   Apache Modules
Correct Answer: A, C and D
Explanation: Common Gateway Interface (CGI), Netscape Server API (NSAPI) and Apache Modules, are competitive technologies of Java Servlet technology. Hence options A, C and D are correct. Option B is incorrect because JSP is an alternate technology.

Q7. Which of the following Servlet lifecycle methods are executed once?
Answer choices: (Select 2)
A.   init
B.   service
C.   destroy
D.   doGet
Correct Answer: A and C
Explanation: The Java Servlet lifecycle methods init and destroy are executed once in the lifecycle. Hence options A and C are correct. The options B and D are incorrect because it is not executed once.

Q8. Your application design requires a pool of servlet instances. Which interface should you inherit to force this property?
Answer choices: (Select best answer)
A.   SingleThreadModel
B.   MultipleThreadModel
C.   No interface
D.   SingleProcessModel
Correct Answer: A
Explanation: Java Servlets implement the SingleThreadModel interface which guarantees there is one thread at a time executing the service method. Servlet containers may maintain a pool of servlet instances. Hence option A is correct. The other options are invalid.

Q9. Which of the following are exceptions thrown by a Servlet?
Answer choices: (Select 2)
A.   ServletException
B.   UnavailableException
C.   ServletUnavailableException
D.   ServletError
Correct Answer: A and B
Explanation: A Servlet may throw either ServletException or UnavailableException when the service method is executed. Hence options A and B are correct. The other options C and D are incorrect.

Q10. Which of the following are session tracking mechanisms?
Answer choices: (Select 3)
A.   Cookies
B.   URL rewriting
C.   HTTPSession
D.   Form fields
Correct Answer: A, B and C
Explanation: Session tracking mechanisms include cookies, URL rewriting and HTTP session which makes options A, B and C valid choices. The option D is incorrect because form fields are not used to track sessions.

OBJECTIVE: Explain standard uses for Java Server Faces components in a typical Java EE application.

Q1. You are discussing the key features of JSF with your team. Which points will you highlight?
Answer choices: (Select 3)
A.   Reuse existing UI components
B.   Manages UI state across requests
C.   Custom UI components difficult to build
D.   Easy development of custom UI components
Correct Answer: A, B and D
Explanation: The key features of JSF include the ability to reuse existing UI components, maintain UI state across requests and easily developed custom UI components. Hence options A, B and D are correct answers. Option C is incorrect because custom UI components are not difficult to build.

Q2. You are negotiating with the client about the challenges associated with the web applications and how JSF addresses those challenges. Which points will you discuss?
Answer choices: (Select 3)
A.   Support form processing
B.   Validation
C.   No event model
D.   Error handling
Correct Answer: A, B and D
Explanation: JSF has support for form processing, validation and error handling. It also has a strongly typed event model. Hence options A, B and D are correct, and option C is incorrect.

Q3. You are discussing the roles that a JSF developer plays. Which of the following roles are valid?
Answer choices: (Select 3)
A.   Page author
B.   Application architect
C.   Component writer
D.   Tool provider
Correct Answer: A, C and D
Explanation: The roles played by a JSF developer include a page author, component writer, application developer, tool provider and implementer. Hence options A, C and D are correct, and option B is incorrect.
Q4. Which of the following are different scenarios that occur in a JSF application?
Answer choices: (Select 3)
A.   Non-faces request generates faces response
B.   Faces request generates faces response
C.   Faces request generates non-faces response
D.   Non-faces request generates non-faces response
Correct Answer: A, B and C
Explanation: The different scenarios that may occur in a JSF application include a faces and non-faces request generating a faces response and faces request generating a non-faces response. Hence options A, B and C are correct, and option D is incorrect.

Q5. Which phase of JSF life cycle builds the view of the page, wires event handlers and validators?
Answer choices: (Select best answer)
A.   Restore view
B.   Apply request values
C.   Invoke application
D.   Render response
Correct Answer: A
Explanation: The restore view phase is the first phase of the JSF lifecycle which builds the view of the phase, wires event handlers and validators, and saves the view in the FacesContext instance which contains all information needed to process a single request. Hence option A is the correct choice. All other options are incorrect.

Q6. Which phase of JSF life cycle uses the decode method to extract new value from the request parameters?
Answer choices: (Select best answer)
A.   Restore view
B.   Apply request values
C.   Invoke application
D.   Render response
Correct Answer: B
Explanation: The apply request values phase is the second phase in the JSF lifecycle where the decode method is used to extract the new value of the component from the request parameters. Hence option B is correct. All other options are incorrect.

Q7. Which phase of JSF life cycle processes all validators registered in the component tree?
Answer choices: (Select best answer)
A.   Restore view
B.   Apply request values
C.   Process validations
D.   Render response
Correct Answer: C
Explanation: The process validations phase processes all validators in the component tree. It examines the component attributes that specify the rules for the validation and adds error messages if the local value is invalid. Hence option C is correct. All other options are incorrect.

Q8. Which phase of JSF life cycle walks the component tree and sets the corresponding server-side properties to local value?
Answer choices: (Select best answer)
A.   Update model values
B.   Apply request values
C.   Process validations
D.   Render response
Correct Answer: A
Explanation: The update model values phase traverses the component tree and sets the server-side object properties to local value of the component. It only updates the bean properties pointed by input components value attribute. Hence option A is correct. All other options are incorrect.
Q9. Which phase of JSF life cycle handles application-level events?
Answer choices: (Select best answer)
A.   Update model values
B.   Invoke applications
C.   Process validations
D.   Render response
Correct Answer: B
Explanation: The invoke applications phase handles application-level events. Hence option B is correct. All other options are incorrect.

Q10. Which phase of JSF life cycle renders the page?
Answer choices: (Select best answer)
A.   Update model values
B.   Invoke applications
C.   Process validations
D.   Render response
Correct Answer: D
Explanation: The render response phase is responsible for rendering the page. The components will render as the JSP container traverses the tags in the page. Hence option D is correct. All other options are incorrect.

Objective: Given a system requirements definition, explain and justify your rationale for choosing a web-centric or EJB-centric implementation to solve the requirements. Web-centric means that you are providing a solution that does not use EJB components. EJB-centric solution will require an application server that supports EJB components.

Q1. A large retail customer has a requirement for a complex transaction processing system with existing system integration. As an architect, what would you recommend?
Answer choices: (Select best answer)
A.   EJB-centric system with no external system
B.   Web-centric system with external system
C.   EJB-centric system with external system
D.   Web-centric system with no external system
Correct Answer: C
Explanation: EJB-centric systems are candidates where transaction processing is required. The existing external system will need to be integrated using Java EE technology. Hence the option C is the right answer. All other options are incorrect.  

Q2. You are the architect of a small B2C website where ease of development is the primary concern. Which type of architecture would you recommend?
Answer choices: (Select best answer)
A.   EJB-centric system with no external system
B.   Web-centric system with external system
C.   EJB-centric system with external system
D.   Web-centric system with no external system
Correct Answer: D
Explanation: When ease of development is the primary concern and a small B2C site needs to be developed, a Web-centric architecture is recommended. Hence option D is correct. All other options are incorrect.  

Q3. A banking system requires role based security for the mortgage website. Which type of architecture would you recommend?
Answer choices: (Select best answer)
A.   EJB-centric system with no external system
B.   Web-centric system with external system
C.   EJB-centric system with external system
D.   Web-centric system with no external system
Correct Answer: A
Explanation: EJB-centric systems can successfully satisfy the requirement of role-based security. Here, no external system integration is required unless explicitly specified. Hence option A is correct. All other options are incorrect.  

Q4. The development team does not have EJB skills. The website you are developing requires integration with an inventory system. Which type of architecture would you recommend?
Answer choices: (Select best answer)
A.   EJB-centric system with no external system
B.   Web-centric system with external system
C.   EJB-centric system with external system
D.   Web-centric system with no external system
Correct Answer: B
Explanation: One of the primary concerns making a technology decision is to check the skills of the development team. If the development team does not have EJB skills, it is recommended to use a Web-centric architecture. The architecture can be integrated with an inventory system. Hence option B is the correct answer. All other options are incorrect.  

Q5. A back office system is required to update the details in a banking system. Which type of architecture would you recommend?
Answer choices: (Select best answer)
A.   EJB-centric system with no external system
B.   Web-centric system with external system
C.   EJB-centric system with external system
D.   Web-centric system with no external system
Correct Answer: A
Explanation: The requirement is to update the details in the banking system via MDBs. Hence option A is the correct choice. The other options do not address the question.