Location WGS-PREX-J080-75 Web Component Developer The by aof75410

VIEWS: 8 PAGES: 33

									                                   A Practice Exam
                       Sun Certified Web Component Developer
Location: WGS-PREX-J080-75: Web Component Developer > The Servlet Model > Objective 1.1
> Item 1
1. Given the HttpServlet method:
         doGet(HttpServletRequest, HttpServletResponse)
   Which statement is true?

  A       It returns servlet version information.
  B       It returns servlet context information.
  C       It services an HTTP GET request.
  D       It services an HTTP OPTIONS request.

Answer:
Option C is correct because the doGet(HttpServletRequest, HttpServletResponse) method is
used to service an HTTP GET request.
Options A and B are incorrect because the doGet method does not return servlet version or
context information. The getServletInfo method returns servlet version information. The
getServletContext method returns servlet context information.
Option D is incorrect because the doGet method does not service an HTTP OPTIONS request.
The doOptions method is used to service an HTTP OPTIONS request.

References: Documentation
     Java Servlet Specification Version 2.3 - The Servlet Interface - Request Handling
     Methods - HTTP Specific Request Handling Methods

Location: WGS-PREX-J080-75: Web Component Developer > The Servlet Model > Objective 1.1
> Item 2
2. Which method of HttpServlet should be overridden by a subclass of HttpServlet to handle
   an HTTP PUT request?

  A       doPut(ServletRequest, ServletResponse)
  B       put(HttpServletRequest, ServletResponse)
  C       servicePut(ServletRequest, ServletResponse)
  D       doPut(HttpServletRequest, HttpServletResponse)

Answer:
Option D is correct because a subclass needs to override the doPut() method to handle the
HTTP PUT requests.
Option A is incorrect because it does not show the correct parameters being passed.
Options B and C are incorrect because there are no such methods in HttpServlet.

References:   Documentation
     Java Servlet Specification Version 2.3 - The Servlet Interface - Request Handling
     Methods - HTTP Specific Request Handling Methods

Location: WGS-PREX-J080-75: Web Component Developer > The Servlet Model > Objective 1.2
> Item 1
3. Which two are true of using the HTTP GET method for a form submission? (Choose two.)

  A         Form data set is included in the body of the form.
  B         It restricts form data set values to ASCII characters.
  C         It allows the client to send data of unlimited length.
  D         Only the request headers are returned in the response without the body.
  E         Form data set is appended to the URI specified by the action attribute with "?" as
        separator.

Answer:
Options B and E are correct. The GET method appends "?" as a separator to the data. The
GET method also restricts the form data set to ASCII character.
Options A and C are incorrect because they are true for POST and NOT for GET.
Option D is incorrect because GET returns the body along with the header.

References: Documentation
     HTML 4.01 Specification - http://www.w3.org/TR/html4/

Location: WGS-PREX-J080-75: Web Component Developer > The Servlet Model > Objective 1.2
> Item 2
4. Given:

  1.   <html>
  2.   <body>
  3.     <form action="/servlet/TestServlet">
  4.         <input type="submit" value="POST">
  5.     </form>
  6.   </body>
  7.   </html>

Which HTTP method is used to submit the form?

  A        GET
  B        POST
  C        HEAD
  D        OPTIONS

Answer:
Option A is correct because the default method of submission of form is via GET.
Options B, C, and D are not the correct method of submission.

References: Documentation
     HTML 4.01 Specification - http://www.w3.org/TR/html4/

Location: WGS-PREX-J080-75: Web Component Developer > The Servlet Model > Objective 1.3
> Item 1
5. Which method returns an array containing all of the parameter values associated with a
   parameter name in an HTTP POST request?
  A       getParameter method of the ServletRequest interface
  B       getParameters method of the HttpServletRequest interface
  C       getParameterNames method of the ServletRequest interface
  D       getParameterValues method of the ServletRequest interface
  E       There is no method for retrieving all parameter values.

Answer:
Option D is correct because the getParameterValues method of the ServletRequest interface is
the correct method to obtain the list of all parameter values for a given parameter name.
Option A is incorrect because the getParameter method does not return an array.
Option B is incorrect because the getParameters method of HttpServletRequest does not exist.
Option C is incorrect because the getParameterNames method returns the names, not values.
Option E is incorrect because a method exists by which all parameter values associated with a
parameter name can be retrieved.

References:   Documentation
     Java Servlet Specification Version 2.3 - The Servlet Interface - Request Handling
     Methods - HTTP Specific Request Handling Methods

Location: WGS-PREX-J080-75: Web Component Developer > The Servlet Model > Objective 1.3 >
Item 2
6. You need to write binary data in response to a request to the Servlet. Which method do you
   use to acquire the required stream for accomplishing this?

  A       getWriter method of the ServletResponse interface
  B       getDataOutputStream of the ServletRequest interface
  C       getDataOutputStream of the ServletResponse interface
  D       getOutputStream method of the ServletResponse interface

Answer:
Option D is correct. The getOutputStream method is the correct method to obtain the stream
for writing binary stream.
Option A is incorrect because the getWriter method returns a writer suitable for writing text.
Options B and C are incorrect. The getDataOutputStream method does not exist in the
ServletResponse and ServletRequest interfaces.

References:   Documentation
     Java Servlet Specification Version 2.3 - The Servlet Interface - Request Handling
     Methods

Location: WGS-PREX-J080-75: Web Component Developer > The Servlet Model > Objective 1.4 >
Item 1
7. Which is true of the getResource method of the ServletContext interface?

  A       It uses a Class Loader to look up the resource.
  B       It is used to obtain the dynamic content of the resource.
  C       It returns a URL to the resource that is mapped to the specified path.
  D       It returns an InputStream object to the resource located at the specified path.
Answer:
Option C is correct because getResource method of ServletContext interface returns a URL.
Option A is incorrect because the getResource method does not use a Class Loader, unlike
java.lang.Class.getResource.
Option B is incorrect because the getResource method returns the static content and not the
dynamic content.
Option D is incorrect because getResourceAsStream method returns the InputStream object.

References:   Documentation
     Java Servlet Specification Version 2.3 - Servlet Context

Location: WGS-PREX-J080-75: Web Component Developer > The Servlet Model > Objective 1.5
> Item 1
8. Click the Exhibit button.
   Which three methods are called when TestServlet receives an HTTP POST request for the
   first time? (Choose three.)
   A        init
   B        doGet
   C        doPost
   D        Service

 1. import java.io.*;
 2. import javax.servlet.*;
 3. import javax.servlet.http.*;
 4.
 5. public class TestServlet extends HttpServlet {
 7. public void init(ServletConfig config) throws ServletException {
 9.    System.out.println("Inside init");
10. }
11.
12. public void doGet (HttpServletRequest request, HttpServletResponse response)
14.                  throws ServletException, IOException   {
16.    System.out.println("Inside doGet");
17. }
18.
19. public void doPost (HttpServletRequest request, HttpServletResponse response)
21.                  throws ServletException, IOException {
23.    System.out.println("Inside doPost");
24. }
25.
26. public void destroy() {
28.    System.out.println("Inside destroy");
29. }
30. }

Answer:
Options A, C, and D are correct. The first time request calls init. Then the default service
method is called by the servlet container. The service method in turn calls the doPost method.
Option B is incorrect because the HTTP request type is a POST and not a GET.
References: Documentation
     Java Servlet Specification Version 2.3 - The Servlet Interface

Location: WGS-PREX-J080-75: Web Component Developer > The Servlet Model > Objective 1.6
> Item 1
9. Which two interfaces define method(s) to obtain a RequestDispatcher object? (Choose two.)

  A       HttpSession
  B       ServletRequest
  C       ServletContext
  D       ServletResponse

Answer:
Options B and C are correct. The ServletRequest and ServletContext interfaces define the
getRequestDispatcher method.
Options A and D are incorrect because there are no methods defined to obtain a
RequestDispatcher object.

References:   Documentation
     Java Servlet Specification Version 2.3 - Servlet Context

Location: ... > Objective 2.1 > Item 1
10. Which directory stores the deployment descriptor for a Web application located in the
  myweb directory?

  A       myweb/WEB-INF
  B       myweb/WEB-INF/lib
  C       myweb/WEB-INF/catalog
  D       myweb/WEB-INF/classes

Answer:
Option A is correct because the deployment descriptor for a Web application located in the
myweb directory is located in the myweb/WEB-INF directory.
Option B is incorrect because the myweb/WEB-INF/lib directory stores the JAR files for the
Web application.
Option C is incorrect because catalog is not a valid directory in the myweb/WEB-INF
directory.
Option D is incorrect because the myweb/WEB-INF/classes directory stores the servlet and
utility classes for the Web application.

References:   Documentation
     Java Servlet Specification Version 2.3 - Web Applications - Directory Structure

Location: ... > Objective 2.1 > Item 2
11. Which statement is NOT true regarding the WEB-INF directory?

  A       The deployment descriptor resides directly under that directory.
  B       Files contained in that directory can be served directly to the client.
   C       It contains all things related to the Web application that are not in the document root
of the application.
   D       The classes subdirectory under WEB-INF contains all of the servlet/utility classes
required by the Web application.

Answer:
Option B is correct. Files contained under the WEB-INF directory cannot be served directly to
the client. Class Loader will load the files.
Options A, C, and D are true statements regarding the WEB-INF directory.

References:   Documentation
     Java Servlet Specification Version 2.3 - Web Applications - Directory Structure

Location: ... > Objective 2.1 > Item 3
12. Under which directory should you place the JAR files used by the Web application?

  A       /WEB-INF
  B       /WEB-INF/lib
  C       /WEB-INF/classes
  D       /WEB-INF/serverclasses

Answer:
Option B is correct. JAR files should be placed in the /WEB-INF/lib directory.
Option A is incorrect because deployment descriptors are normally stored in the /WEB/INF
directory.
Option C is incorrect because class files are stored in the /WEB-INF/classes directory.
Option D is incorrect because the /WEB-INF/serverclasses directory is not defined as part of
the file structure of a Web application.

References:   Documentation
     Java Servlet Specification Version 2.3 - Web Applications - Directory Structure

Location: ... > Objective 2.2 > Item 1
13. Which element contains the fully qualified class name of the servlet in the deployment
  descriptor?
  A       servlet
  B       servlet-name
  C       servletclass
  D       servlet-class

Answer:
Option D is correct because the servlet-class element is the correct element for the class name of
a servlet.
Options A, B, and C are incorrect because they do not contain the fully qualified class name of
the servlet in the deployment descriptor.

References:   Documentation
     Java Servlet Specification Version 2.3 - Deployment Descriptor - DTD
Location: ... > Objective 2.2 > Item 2
14. Which element in the deployment descriptor defines a mapping between a servlet and a
URL pattern?

  A       servlet-url
  B       url-pattern
  C       url-mapping
  D       servlet-mapping

Answer:
Option D is correct. The servlet-mapping element in the deployment descriptor defines a
mapping between a servlet and a URL pattern.
Options A, B, and C are incorrect because they do not define the mapping.

References: Documentation
     Java Servlet Specification Version 2.3 - Deployment Descriptor - DTD

Location: ... > The Servlet Container Model > Objective 3.1 > Item 1
15. Which three methods of the HttpSessionAttributeListener interface must a class implement
  to get notification of changes to the attribute lists of sessions within a Web application?
  (Choose three.)

  A        attributeAdded
  B        attributeUpdated
  C        attributeRemoved
  D        attributeModified
  E         attributeReplaced

Answer:
Options A, C, and E are correct. The attributeAdded, attributeRemoved, and
attributeReplaced methods of the HttpSessionAttributeListener interface provide notification
of changes to the attribute lists of sessions within a Web application.
Options B and D are not defined in the interface.

References:   Documentation
     Java Servlet Specification Version 2.3 - API Details - HttpSessionAttributeListener

Location: ... > The Servlet Container Model > Objective 3.1 > Item 2
16. Which event is received by the appropriate listeners that get notifications of changes to the
  attribute lists of sessions within a Web application?

  A       SessionBindingEvent
  B       AttributeChangeEvent
  C       HttpSessionBindingEvent
  D       HttpAttributeChangeEvent
Answer:
Option C is correct. The HttpSessionBindingEvent is received by the listeners that get
notifications of changes to the attribute lists.
Options A, B, and D are incorrect because the SessionBindingEvent,
HttpAttributeChangeEvent, and AttributeChangeEvent events are not valid events.

References:   Documentation
     Java Servlet Specification Version 2.3 - API Details - HttpSessionAttributeListener

Location: ... > Objective 2.2 > Item 1
17. Which element in the deployment descriptor is used to specify the properties of a Servlet
  Context Listener?

  A       listener
  B       contextlistener
  C       context-listener
  D       context-listener-class

Answer:
Option A is correct because the listener element specifies the properties of a Servlet Context
Listener.
Options B, C, and D are incorrect because the context listener, contextlistener, and context-
listener-class elements are not valid property descriptor elements.

References:   Documentation
     Java Servlet Specification Version 2.3 - Deployment Descriptor - DTD

Location: ... > The Servlet Container Model > Objective 3.2 > Item 2
18. The class com.acme.MyContextListener implements javax.servlet.ServletContextListener.
  Which deployment descriptor registers the ServletContextListener?

  A       <listener> com.acme.MyContextListener </listener>
  B       <context-listener> com.acme.MyContextListener </context-listener>
  C       <listener>
          <listener-class> com.acme.MyContextListener </listener-class>
          <listener>
  D       <context-listener>
          <context-listener-class> com.acme.MyContextListener </context-listener-class>
          </context-listener>
Answer:
Option C is correct because the ServletContextListener class is specified by the format:
<listener>
<listener-class> class name of the listener </listener-class>
</listener>
Options A, B, and D are incorrect because they will not specify the ServletContextListener.

References:   Documentation
     Java Servlet Specification Version 2.3 - Application Lifecycle Events - Configuration of
     Listener Classes
Location: ... > The Servlet Container Model > Objective 3.3 > Item 1
19. Which interface must an attribute bound to a session implement so that it can be notified
  when a container migrates session between VMs or persists sessions?

  A       HttpSessionBindingListener
  B       HttpSessionMigrationListener
  C       HttpSessionActivationListener
  D       HttpSessionPassivationListener
  E       HttpSessionPersistenceListener

Answer:
Option C is correct. A container that migrates session between VMs or persists sessions is
required to notify all attributes bound to sessions implementing HttpSessionActivationListener.
Options A, B, D, and E are incorrect because the container notifies only those attributes that
implement the HttpSessionActivationListener interface.

References: Documentation
     Java Servlet Specification Version 2.3 - API Details

Location: ... > Objective 4.1 > Item 1
20. In which class are the methods sendError and setStatus used to cause an HTTP error to be
  returned?

  A       HttpSessionEvent
  B       HttpServletResponse
  C       HttpSessionBindingEvent
  D       HttpServletRequestWrapper

Answer:
Option B is correct because the sendError and setStatus methods are defined in the
HttpServletResponse class. The methods are used to cause an HTTP error to be returned in
the servlet's response.
Options A, C, and D are incorrect because the HttpSessionEvent, HttpSessionBindingEvent,
and HttpServletRequestWrapper classes do not contain the sendError and setStatus methods.

References:   Documentation
     Java Servlet Specification Version 2.3 - API Details – HttpServletResponse

Location: ... > Objective 4.1 > Item 2
21. Click the Exhibit button.
  If MyServlet receives an HTTP POST request, which exception, if any, will the sendError
  method in HttpServletResponse throw?

  A       InvalidStateException
  B       IllegalStateException
  C       InvalidBufferException
  D       IllegalArgumentException
  E       no exception will be thrown
Answer:
Option B is correct. If the response is committed, this method will throw IllegalStateException.
Options A, C, D, and E are incorrect because the IllegalArgumentException,
InvalidStateException, and InvalidBufferException exceptions will not be thrown by the
sendError method.

References:   Documentation
     Java Servlet Specification Version 2.3 - The Response - Convenience Methods

Location: ... > Objective 4.2 > Item 1
22. Which is a valid child element of the <web-app> element within the Web application
  deployment descriptor?

  A       <location>
  B       <res-type>
  C       <error-page>
  D       <param-name>

Answer:
Option C is correct because the <error-page> element is a child element of the <web-app>
element within the Web application deployment descriptor.
Option A is incorrect because the parent element for the <location> element is <error-page>.
Option B is incorrect because the parent element for the <res-type> element is <resource-ref>.
Option D is incorrect because the parent element for the <param-name> element is <init-
param>.

References: Documentation
     Java Servlet Specification Version 2.3 - Deployment Descriptor – DTD

Location: ... > Objective 4.2 > Item 2
23. Which element in the Deployment Descriptor contains a mapping between an error code or
  exception type to the path of a resource in the Web application?

  A       error-page
  B       error-code
  C       error-resource
  D       exception-type

Answer:
Option A is correct. The error-page element contains a mapping between an error code or
exception type to the path of the resource.
Options B, C, and D are incorrect because the exception-type, error-resource, and error-code
elements do not refer to the error code mapping.

References:   Documentation
     Java Servlet Specification Version 2.3 - Deployment Descriptor Version 2.2

Location: ... > Objective 4.2 > Item 2
24. Which two classes provide methods that write to the WebApp log? (Choose two.)

  A       HttpServlet
  B       HttpRequest
  C       HttpSession
  D       ServletContext
  E       HttpServletResponse

Answer:
Options A and D are correct because both classes, HttpServlet and ServletContext, contain the
log method for writing to the WebApp log.
Options B, C, and E are incorrect because the HttpRequest, HttpSession, and
HttpServletResponse classes do not contain the log method for writing to the WebApp log.

References:   Documentation
     Java Servlet Specification Version 2.3 - API Details

Location: ... > Designing and Developing Servlets Using Session Management > Objective 5.1 >
Item 1
25. Which method is used to store an object in the session?

  A       setValue
  B       putObject
  C       storeObject
  D       SetAttribute

Answer:
Option D is correct. The setAttribute method is used to store an object in the session.
Options A, B, and C are incorrect because the storeObject, putObject, and setValue methods
do not store an object in the session.

References: Documentation
     Java Servlet Specification Version 2.3 - API Details – HttpSession

Location: ... > Designing and Developing Servlets Using Session Management > Objective 5.1 >
Item 2
26. Click the Exhibit button.
   Assuming servlets X and Y are in the same Web Application, and given that the HTTP
   requests are fully processed in this order:
       1. POST method to X
       2. POST method to Y

  What is the result?

  A       Compilation fails.
  B       An exception is thrown in servlet Y.
  C       An exception is thrown in servlet X.
  D       "123" is returned in the generated servlet response.
  E       "null" is returned in the generated servlet response.
Code for X.java:
1. public class X extends HttpServlet
2. {
3. public void doPost(HttpServletRequest req, HttpServletResponse rsp)
4. {
5.    int value = 123;
6.    req.getSession().setAttribute(“value”,value);
7. }
8. }

Code for Y.java:
1. public class Y extends HttpServlet
2. {
3. public void doPost(HttpServletRequest req, HttpServletResponse rsp)
4.               throws IOException
5. {
6.    int value = ((Integer) req.getSession().getAttribute("value")).intValue();;
7.    rsp.getWriter().println(value);
8. }
9. }

Answer:
Option A is correct. The setAttribute method is used to store an object in the session. The value
variable of type 'int' cannot be passed as an argument.
Options B, C, D, and E are incorrect because compilation fails.

References:   Documentation
     Java Servlet Specification Version 2.3 - API Details – HttpSession

Location: ... > Designing and Developing Servlets Using Session Management > Objective 5.2 >
Item 1
27. Given this deployment descriptor element for a Web application:
          <session-config>
          <session-timeout>600</session-timeout>
          </session-config>
   What is the default session timeout interval for all the sessions created in this Web
   application?

  A       600 min
  B       600 sec
  C       600 msec
  D       600 hours

Answer:
Option A is correct. The timeout specified is expressed in whole number of minutes.
Options B, C, and D are incorrect, because the timeout interval for the session is specified in
minutes.
References:   Documentation
     Java Servlet Specification Version 2.3 - Deployment Descriptor Version 2.2

Location: ... > Designing and Developing Servlets Using Session Management > Objective 5.3 >
Item 1
28. URL Rewriting must be used for sharing state information between client and server.
When the specified URL is encoded, what is included in the URL that gets written out in the
servlet's response output stream?
   A        user ID
   B        session ID
   C        IP address
   D        domain name
   E        machine name

Answer:
Option B is correct. The session ID is iincluded in the URL when the URL is encoded.
Options A, C, D, and E are incorrect. They are not included when the encoding of URL is done
in a URL rewrite.

References: Documentation
     Java Servlet Specification Version 2.3 - API Details – HttpServletResponse

Location: ... > Designing and Developing Secure Web Applications > Objective 6.1 > Item 1
29. Which correctly defines authorization?
  A       Authorization uses encryption to send user data.
  B       Authorization verifies that a user is really what he claims to be.
  C       Authorization ensures that nobody intercepts the data during transmission.
  D       Authorization verifies that a user has access to a specific resource on the Web server.

Answer:
Option D is correct because authorization verifies that a user has access to a specific resource
on the Web server.
Option B is incorrect because authentication verifies that a user is really what he claims to be
via passphrase.
Options A and C are incorrect.

References: Documentation
     Java Servlet Specification Version 2.3 – Security

Location: ... > Designing and Developing Secure Web Applications > Objective 6.2 > Item 1
30. Given these deployment descriptor elements:
         security-constraint
         login-config
         security-role
  What requires these elements during configuration?
  A        authorization of Web Services
  B        data integrity of Web Services
  C        authentication of Web Services
  D        reference sharing of Web Services
Answer:
Option A is correct because configuring the authorization of Web Services requires the
deployment descriptor elements: security-constraint, login-config, and security-role.
Options B, C, and D are incorrect because these three deployment descriptor elements are not
required for configuring data integrity, authentication, and reference sharing of Web Services.

References: Documentation
     Java Servlet Specification Version 2.3 - Deployment Descriptor – DTD

Location: ... > Designing and Developing Secure Web Applications > Objective 6.2 > Item 2
31. Which three are valid values for the transport-guarantee deployment descriptor element?
  (Choose three.)
  A       NONE
  B       SECURE
  C       INTEGRAL
  D       PLAINTEXT
  E       CONFIDENTIAL

Answer:
Options A, C, and E are correct. These values are valid values for the transport-guarantee
deployment descriptor element.
Options B and D are incorrect because they are not valid values.

References: Documentation
     Java Servlet Specification Version 2.3 - Deployment Descriptor Version 2.2

Location: ... > Designing and Developing Secure Web Applications > Objective 6.3 > Item 1
32. Which auth-method element value in a deployment descriptor specifies a strong
  authentication mechanism to be used between client and server?
  A       FORM
  B       BASIC
  C       DIGEST
  D       CLIENT-CERT

Answer:
Option D is correct because the CLIENT-CERT value specifies the HTTPS Client
Authentication to be used.
Options A, B, and C are incorrect because they do not specify HTTPS Client Authentication.

References: Documentation
     Java Servlet Specification Version 2.3 - Security - Authentication
     Java Servlet Specification Version 2.3 - Deployment Descriptor Version 2.2

Location: ... > Designing and Developing Secure Web Applications > Objective 6.3 > Item 2
33. When using the HTTP Digest Authentication, in which form is the password transmitted?
  A       unicode
  B       encrypted
  C       decrypted
  D       plain text
Answer:
Option B is correct because HTTP Digest Authentication encrypts the password before it is
transmitted.
Options A, C, and D are incorrect because the HTTP Digest Authentication does not use the
unicode, decrypted, or plain text forms when transmitting the password.

References:   Documentation
     Java Servlet Specification Version 2.3 - Security - HTTP Digest Authentication

Location: ... > Designing and Developing Secure Web Applications > Objective 6.3 > Item 3
34. Which auth-method element value in a deployment descriptor allows the developer to
control the look and feel of the login screen?

  A       FORM
  B       BASIC
  C       HTML-FORM
  D       HTTP-POST
  E       CLIENT-CERT

Answer:
Option A is correct because the FORM element allows the developer to control the look and
feel of the login screen.
Options B and E are incorrect because BASIC and CLIENT-CERT do not specify anything
about the look and feel.
Options C and D are not valid values for the auth-method element.

References: Documentation
     Java Servlet Specification Version 2.3 - Security - Form Based Authentication

Location: ... > Designing and Developing Thread-safe Servlets > Objective 7.1 > Item 1
35. Given:
  1. public class MyServlet extends HttpServlet implements SingleThreadModel {
  2.   private static StringBuffer value = new StringBuffer("123");
  3.   public void doPost(HttpServletRequest req, HttpServletResponse resp) {
  4.     System.out.println("Inside doPost");
  5.   }
  6. }

 Which statement is true?

  A       Both variable value and variable req are thread safe.
  B       Both variable value and variable req are not thread safe.
  C       Variable value is thread safe and variable req is not thread safe.
  D       Variable value is not thread safe and variable req is thread safe.

Answer:
Option A is correct because the variables req and value are both thread safe.
Options B, C, and D are incorrect.
References:   Documentation
     Java Servlet Specification Version 2.3 - API Details – SingleThreadModel

Location: ... > Designing and Developing Thread-safe Servlets > Objective 7.2 > Item 1
36. Which two are true of servlets that implement the SingleThreadModel? (Choose two.)

  A         The container synchronizes access to all variables.
  B         The container may synchronize access to a single instance of the servlet.
  C         The container ensures that there is only a single instance of the servlet.
  D         The container guarantees that no two threads will execute concurrently in the
servlet's service method.

Answer:
Options B and D are correct.
Option A is incorrect because the container does not synchronize access to all variables.
Option C is incorrect because the container may create multiple instances of the servlet.

References: Documentation
     Java Servlet Specification Version 2.3 - API Details – SingleThreadModel

Location: ... > Designing and Developing Thread-safe Servlets > Objective 7.3 > Item 1
37. Which method from the SingleThreadModel interface must a servlet implement to use the
  single thread model?

  A       lock
  B       service
  C       release
  D       synchronize
  E       No methods need to be implemented.

Answer:
Option E is correct because the SingleThreadModel interface does not have any methods.
Options A, B, C, and D are incorrect because the interface does not include the specified
methods.

References: Documentation
     Java Servlet Specification Version 2.3 - API Details – SingleThreadModel

Location: WGS-PREX-J080-75: Web Component Developer > The JSP Model > Objective 8.1 >
Item 1
38. Given:
   1. <html>
   2. <body>
   3.
   4.   <% x = x + 50; >
   5.   Set it to: <%= x %>
   6. </body>
   7. </html>
  What should be inserted on line 3 to allow translation and compilation to succeed, and allow
  the output of "Set it to: 94"?

  A       <% int x = 44 %>
  B       <%@ int x = 44 %>
  C       <%! int x = 44; %>
  D       <%! int x = 44; !%>
  E       <%@ int x = 44; @%>

Answer:
Option C is correct because it is a correct JSP declaration.
Option A is incorrect because there is no semicolon at the end.
Options B and E are incorrect because they are JSP include directives and they must begin
with <%@ and end with %>.
Option D is incorrect because a JSP declaration must end with %>.

References:  Documentation
     JavaServer Pages Specification Version 1.2 - Core Syntax and Semantics - Scripting
     Elements - Expressions

Location: WGS-PREX-J080-75: Web Component Developer > The JSP Model > Objective 8.1 >
Item 2
39. Click the Exhibit button.
   What is printed in the response generated?

  A       Value of i is: 12
  B       Value of i is: 13
  C       Value of i is: null
  D       Compilation fails.

 1. <html>
 2.
 3. <head>
 4. </head>
 5.
 6. <body>
 7.   <%! int i; %>
 8.   <% i = 12; %>
 9.   Value of i is: <% = ++i %>
10. </body>
11.
12. </html>

Answer:
Option D is correct. Because there is an extra space in the opening tag for the expression,
compilation fails.
Options A, B, and C are incorrect because compilation fails.
References: Documentation
     JavaServer Pages Specification Version 1.2 - Core Syntax and Semantics

Location: WGS-PREX-J080-75: Web Component Developer > The JSP Model > Objective 8.2 >
Item 1
40. Click the Exhibit button.
   What is printed in the response generated?

  A       Value of i is: 12
  B       Value of i is: 13
  C       Value of i is: null
  D       Compilation fails.

 1. <html>
 2.
 3. <head>
 4. </head>
 5.
 6. <body>
 7.   <%! int i; %>
 8.   <%! i = 12; %>
 9.   Value of i is: <%= ++i %>
10. </body>
11.
12. </html>

Answer:
Option D is correct because the declaration of setting i to 12 is incorrect.
Options A, B, and C are incorrect because compilation fails.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Core Syntax and Semantics

Location: WGS-PREX-J080-75: Web Component Developer > The JSP Model > Objective 8.3 >
Item 1
41. Which two are equivalent? (Choose two.)

  A       <%@ include ..%>
  B       <jsp:include ../>
  C       <jsp:directive.include ../>
  D       <jsp:include.directive ../>

Answer:
Options A and C are correct because they include the file at translation time.
Option B is incorrect because it includes the file at request time.
Option D is incorrect because it is not a valid element.

References:  Documentation
     JavaServer Pages Specification Version 1.2 - DTD and Schemas for XML Syntax
Location: WGS-PREX-J080-75: Web Component Developer > The JSP Model > Objective 8.4 >
Item 1
42. Which directive declares that a JSP page requires a participation in an HTTP session?

  A       <%@ page session="new" %>
  B       <%@ page session="yes" %>
  C       <%@ page session="true" %>
  D       <%@ page session="http" %>
  E       <%@ page session="false" %>

Answer:
Option C is correct because the following attribute and value declares that a JSP page requires
participation in an HTTP session: <%@ page session="true" %>
Options A, B, D, and E are incorrect because they do not contain the correct value for the
session attribute.

References:  Documentation
     JavaServer Pages Specification Version 1.2 - Core Syntax and Semantics - Directives -
     The page Directive

Location: WGS-PREX-J080-75: Web Component Developer > The JSP Model > Objective 8.4 >
Item 2
43. Which directive declares try.jsp to be the error page for the current test.jsp JSP page?

  A       <%@ page errorPage="this" %>
  B       <%@ page isErrorPage="this" %>
  C       <%@ page errorPage="try.jsp" %>
  D       <%@ page isErrorPage="try.jsp" %>

Answer:
Option C is correct because it contains the correct attribute and value to declare an error page.
Options A, B, and D are incorrect because they do not contain the correct directives for
declaring the error page.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Core Syntax and Semantics - Directives -
     The page Directive

Location: WGS-PREX-J080-75: Web Component Developer > The JSP Model > Objective 8.5 >
Item 1
44. Which phase results in the creation of a servlet class corresponding to the JSP page?

  A       Request Phase
  B       Service Phase
  C       Translation Phase
  D       Initialization Phase
  E       Transformation Phase
Answer:
Option C is correct because the Translation Phase results in a servlet class corresponding to the
JSP page.
Option A is incorrect because the Request Phase will not create a servlet class.
Options B, D, and E are incorrect because they are not valid phases.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Overview - Basic Concepts - Translation
     and Execution Steps

Location: WGS-PREX-J080-75: Web Component Developer > The JSP Model > Objective 8.6 >
Item 1
45. Given this page directive for the try.jsp JSP page:

<%@ page isErrorPage="false" errorPage="test.jsp" session="false" isThreadSafe="false"
%>

 Which two objects are not available for the try.jsp page? (Choose two.)

  A         page
  B         error
  C         thread
  D         session
  E         Exception

Answer:
Options D and E are correct. Because session and isErrorPage attribute values are false, these
two implicit objects are not available.
Options A and B are incorrect because they are always available.
Option C is incorrect because thread is not a valid implicit object.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Core Syntax and Semantics - Objects -
     Implicit Objects
     JavaServer Pages Specification Version 1.2 - Core Syntax and Semantics - Directives -
     The page Directive

Location: WGS-PREX-J080-75: Web Component Developer > The JSP Model > Objective 8.7 >
Item 1
46. Click the Exhibit button.

  What is printed in the response generated?

  A        123
  B        321
  C        Compilation fails.
  D        out.print(3); out.print(2); out.print(1);
  E        out.print(<%=j %>); out.print(<%=j %>); out.print(<%=j %>);
 1. <html>
 2. <head>
 3. </head>
 4.
 5. <body>
 6. <% for (int j=3; j>0; j--)
 7. {
 8. %>
 9.   out.print(<%=j %>);
10. <% }
11. %>
12.
13. </body>
14. </html>

Answer:
Option D is correct. As out.print is not inside a scriptlet, it is literally printed in the response.
Options A, B, C, and E are incorrect.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Core Syntax and Semantics

Location: ... > Designing and Developing Reusable Web Components > Objective 9.1 > Item 1
47. Which statement will insert static text from the tip.jsp file into a JSP page?
  A         <% include file='tip.jsp' %>
  B        <%! include file='tip.jsp' %>
  C         <%@ include file='tip.jsp' %>
  D         <%= include file='tip.jsp' %>

Answer:
Option C is correct because a JSP include directive tag begins with <%@ and ends with %>.
Option A is incorrect because a JSP scriptlet tag begins with <% and ends with %>.
Option B is incorrect because a JSP declaration tag begins with <%! and ends with %>.
Option D is incorrect because a JSP expression tag begins with <%= and ends with %>.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Core Syntax and Semantics - Directives -
     Including Data in JSP Pages

Location: ... > Designing and Developing Reusable Web Components > Objective 9.1 > Item 2
48. Given this code for the test.jsp page:

  1.   <html
  2.   <%@ include file='title.jsp' %>
  3.   <jsp:include page='message.jsp' />
  4.   </html>

  Which statement is true about the test.jsp page?
A   Code at lines 2 and 3 is processed at Request time.
B   Code at lines 2 and 3 is processed at Translation time.
C   Code at line 2 is processed at Request time & code at line 3 is processed at Translation time.
D   Code at line 2 is processed at Translation time & code at line 3 is processed at Request time.

Answer:
Option D is correct because the code at line 2 is processed at Translation time and the code at
line 3 is processed at Request time.
Options A, B, and C are incorrect because they do not correctly identify the phases where the
lines are processed.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Core Syntax and Semantics - Including
     Data in JSP Pages

Location: ... > Designing and Developing Reusable Web Components > Objective 9.1 > Item 3
49. Click the Exhibit button.
  What is printed in the generated response?
  A         i is:3 i is:5
  B         i is:5 i is:3
  C         i is:3 i is:3
  D         i is:5 i is:5
  E         Compilation fails

Code for abc.jsp:
 1. <html>
 2. <head>
 3. </head>
 4.
 5. <body>
 6.   <%! int i=5; %>
 7.   <jsp:include page='xyz.jsp'/>
 8.   i is: <%= i %>
 9. </body>
10. </html>

Code for xyz.jsp:
1. <%! int i=3; %>
2. i is: <%= i %>

Answer:
Option A is correct. Because <jsp:include is used, the output of xyz.jsp is included literally in
the generated response.
Options B, C, and D are incorrect because they do not list the correct value that will be printed.
Option E is incorrect because the code compiles.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Core Syntax and Semantics - Including
     Data in JSP Pages
Location: ... > Designing and Developing JSPs Using JavaBeans > Objective 10.1 > Item 2
50. Click the Exhibit button.
    What is printed in the generated response of sample.jsp?
    A        65
    B        35
    C        65 35
    D        Compilation fails.
Code for abc.java:
 1. package com.acme;
 2.
 3. public class abc
 4. {
 5. private int value;
 6. public abc() { value=35; }
 7. public int getValue() { return value; }
 8. public void setValue(int value) { this.value = value; }
 9. }

Code for xyz.java:
1. package com.acme;
2.
3. public class xyz
4. {
5. private int value;
6. public xyz() { value=65; }
7. public int getValue() { return value; }
8. public void setValue(int value) { this.value = value; }
9. }

Code for sample.jsp:
1. <jsp:useBean class="com.acme.xyz" type="com.acme.abc" id="testBean" />
2. <jsp:getProperty name="testBean" property="value" />

Answer:
Option D is correct. Because xyz is not of type abc, compilation fails.
Options A, B, and C are incorrect because compilation fails.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Standard Actions and Directives -
     <jsp:useBean>

Location: ... > Designing and Developing JSPs Using JavaBeans > Objective 10.1 > Item 1
50. Given:
         <%= bean1.getSize() %>
  What will produce the same results?
  A         <jsp:getProperty bean1.size />
  B        <jsp:getProperty "bean1.size" />
  C         <jsp:getProperty name=bean1 property=size />
  D         <jsp:getProperty name="bean1" property="size" />
Answer:
Option D is correct because the proper syntax for the <jsp:getProperty> action is:
       <jsp:getProperty name="name" property="propertyName" />
The <jsp:getProperty> action retrieves the value of the specified property and converts the
value to a String.
Options A, B, and C are incorrect because they do not use the proper syntax for the
<jsp:getProperty> action.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Standard Actions and Directives -
     <jsp:getProperty>

Location: ... > Designing and Developing JSPs Using JavaBeans > Objective 10.1 > Item 3
52. Which action sets the value of properties in a Bean?
  A         <jsp:setValue>
  B        <jsp:setProperty>
  C         <jsp:setAttribute>
  D         <%jsp:setProperty%>

Answer:
Option B is correct because the <jsp:setProperty> action sets the value of properties in a Bean.
Options A, C, and D are incorrect because they do not identify the correct action to set the
properties in a bean.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Standard Actions and Directives -
     <jsp:setProperty>

Location: ... > Designing and Developing JSPs Using JavaBeans > Objective 10.1 > Item 4
53. Given this code for sample.jsp:
       <jsp:useBean class="com.mycompany.xyz" id="testBean" />

  Which three are true of the xyz class to prevent a compilation error? (Choose three.)
  A xyz cannot be an interface
  B xyz cannnot be an abstract class
  C xyz cannot have a public constructor
  D xyz should have a no-args constructor
  E xyz should declare all the variables as public

Answer:
Options A, B, and D are correct. The xyz class cannot be an interface/abstract class and must
have a no-args constructor.
Option E is incorrect because it is not necessary to declare all the variables to be public.
Option C is incorrect because the xyz class should have a public constructor.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Standard Actions and Directives -
     <jsp:useBean>
Location: ... > Designing and Developing JSPs Using JavaBeans > Objective 10.2 > Item 1
54. Which scope value for the <jsp:useBean> action will store the bean in the ServletContext
object?
   A         page
   B        session
   C         request
   D         context
   E         Application

Answer:
Option E is correct because application scope will store the bean in the ServletContext object.
Options A, B, and C are incorrect. They do not store the bean in the ServletContext object.
Option D is incorrect because context is not a valid scope value.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Standard Actions and Directives -
     <jsp:useBean>

Location: ... > Designing and Developing JSPs Using JavaBeans > Objective 10.3 > Item 1
55. Which attribute of <jsp:setProperty> should be set to * in order to iterate the current set of
the ServletRequest parameters?
   A          name
   B         param
   C          value
   D          property

Answer:
Option D is correct because the property attribute should be set to *.
Options A, B, and C are incorrect because the attributes will not iterate all the parameters of
the request.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Standard Actions and Directives -
     <jsp:setProperty> - Syntax

Location: ... > Designing and Developing JSPs Using JavaBeans > Objective 10.3 > Item 2
56. Click the Exhibit button.
  What is printed in the generated output of sample.jsp?
   A          65
   B         78
   C          null
   D          Compilation fails.

Code for xyz.java:
1. package com.acme;
2.
3. public class xyz
4. {
5.     private int value;
6.     public xyz() { value=65; }
7.     public int getValue() { return value; }
8.     public void setValue(int value) { this.value = value; }
9. }

Code for sample.jsp:
1. <jsp:useBean Class="com.acme.xyz" id="testBean" />
2. <jsp:setProperty id="testBean" property="value" value="78" />
3. <jsp:getProperty id="testBean" property="value" />

Answer:
Option D is correct. The <jsp.setProperty> code must have a name.
Options A, B, and C are incorrect because compilation fails.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Standard Actions and Directives -
     <jsp:setProperty>

Location: ... > Designing and Developing JSPs Using Custom Tags > Objective 11.1 > Item 1
57. How is the <taglib> element in the Web application deployment descriptor used by JSP
pages?

  A           to describe a JSP tag library
  B           to describe a URI identifying a tag library
  C           to describe the session parameters for a tag library
  D           to describe the location of the Tag Library Description file for a tag library

Answer:
Option A is correct because the <taglib> element in the Web application deployment descriptor
is used by JSP pages to describe a JSP tag library.
Option B is incorrect because the <taglib-uri> element is used by JSP pages to describe a URI
identifying a tag library.
Option C is incorrect because a tag library does not include session parameters.
Option D is incorrect because the <taglib-location> element is used to describe the location of
the Tag Library Description file for a tag library.

References: Documentation
     Java Servlet Specification Version 2.3 - Deployment Descriptor – DTD

Location: ... > Designing and Developing JSPs Using Custom Tags > Objective 11.1 > Item 2
58. Which two are mandatory subelements of the <taglib> element? (Choose two.)

  A            id
  B            uri
  C            location
  D            taglib-uri
  E            taglib-location
Answer:
Options D and E are correct. The taglib-uri and taglib-location subelements are mandatory
subelements of the taglib element.
Option A is incorrect because id is an implied attribute and not a subelement.
Options B and C are incorrect because uri and location are not valid subelements.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Tag Extensions - The Tag Library
     Descriptor - Taglib map in web.xml

Location: ... > Designing and Developing JSPs Using Custom Tags > Objective 11.2 > Item 1
59. What is the correct usage of the taglib directive?
   A          %@ taglib uri="/myTagLibrary" %>
   B         <% taglib uri="/myTagLibrary" prefix="myLib" %>
   C          <%@ taglib uri="/myTagLibrary" prefix="myLib" %>
   D          <%! taglib uri="/myTagLibrary" prefix="myLib" %>
   E         <jsp:taglib uri="/myTagLibrary" prefix="myLib" />

Answer:
Option C is correct because it correctly depicts the usage of the taglib directive.
Options A, B, D, and E are incorrect because they do not use the taglib correctly.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Tag Extensions - The Tag Library
     Descriptor - Taglib map in web.xml

Location: ... > Designing and Developing JSPs Using Custom Tags > Objective 11.3 > Item 1
60. Given these specifications for a tag library:
       a tag named getMessage with a mandatory attribute named id and a non-mandatory
attribute named level
       a prefix of myLib
       an empty body tag

  Which three are valid uses of the tag library? (Choose three.)
  A        <myLib:getMessage />
  B        <myLib:getMessage id="12"/>
  C        <myLib:getMessage id="12"></myLib:getMessage>
  D        <myLib:getMessage level="23"></myLib:getMessage>
  E        <myLib:getMessage id="12" level="23"><myLib:getMessage/>
  F        <myLib:getMessage id="12" level="23"></myLib:getMessage>

Answer:
Options B, C, and F are correct. They show the correct usage of the tag.
Options A and D are incorrect because they do not have the id mandatory attribute.
Option E is incorrect because the closing tag is not proper.

References: Documentation
     JavaServer Pages Specification Version 1.2 - JSP Documents - Mapping - Standard and
     Custom Actions
Location: ... > Designing and Developing JSPs Using Custom Tags > Objective 11.3 > Item 2
61. Given these specifications for a tag library:
        * a tag named getValue
        * a prefix of myLib
        * a tag that supports body content
  Which three are valid uses of this tag library? (Choose three.)
   A          </myLib:getValue>
   B         <myLib:getValue />
   C          <myLib:getValue></myLib:getValue>
   D          <myLib:getValue ><myLib:getValue/>
   E         <myLib:getValue >1234</myLib:getValue>

Answer:
Options B, C, and E are correct because they properly use the tag library.
Options A and D are incorrect because they are invalid uses of the tag library.

References: Documentation
     JavaServer Pages Specification Version 1.2 - JSP Documents - Mapping - Standard and
     Custom Actions

Location: ... > Designing and Developing a Custom Tab Library > Objective 12.1 > Item 1
62. Which two tag library descriptor elements identify the class of the tag handler?
   A          tag-class
   B         tag-handler
   C          handlerclass
   D          handler-class
   E         tag-handler-class

Answer:
Option A is correct because tag-class is the correct element for the class of the tag handler.
Options B, C, D, and E are incorrect because tag-handler-class, tag-handler, handlerclass, and
handler-class are not the correct elements.

References: Documentation
     JavaServer Pages Specification Version 1.2 - DTD for TagLibrary Descriptor, JSP 1.2

Location: ... > Designing and Developing a Custom Tab Library > Objective 12.2 > Item 1
63. Which tag library descriptor element identifies the attribute of a tag as optional or
mandatory?
   A          optional
   B         required
   C          mandatory
   D          not-required
   E         not-optional

Answer:
Option B is correct because the required element specifies whether an attribute of a tag is
required.
Options A, C, D, and E are incorrect because optional, mandatory, not-required, and not-
optional are not valid elements for specifying the requirement of an attribute.

References:  Documentation
     JavaServer Pages Specification Version 1.2 - DTD for TagLibrary Descriptor, JSP 1.2

Location: ... > Designing and Developing a Custom Tab Library > Objective 12.3 > Item 1
64. What should be entered in the blank to specify that the body of the tag should be
interpreted by the tag implementation?

       <body-content>______</body-content>

Answer:
The answer is tagdependent. The <body-content> element in the tag library descriptor is used
to provide information about the body of the tag. It specifies one of three values: tagdependent,
JSP, or empty. The tagdependent value specifies that the body of the tag is interpreted by the
tag implementation. The JSP value specifies that the body of the tag contains nested JSP
syntax. The empty value specifies that the body of the tag must be empty.

References: Documentation
     JavaServer Pages Specification Version 1.2 - DTD for TagLibrary Descriptor, JSP 1.2 -
     DTD for TagLibrary Descriptor Files

Location: ... > Designing and Developing a Custom Tab Library > Objective 12.3 > Item 2
65. Which value is used for the body-content tag library descriptor element to indicate that the
body of the tag is interpreted by the tag implementation itself?
   A          JSP
   B         tagspecific
   C          tagdependent
   D          tag-dependent
   E         Tagimplementation

Answer:
Option C is correct because the tagdependent value indicates the body of the tag is interpreted
by the tag.
Option A is incorrect because the JSP value defines that the content has JSP syntax.
Options B, D, and E are incorrect because they are not valid values.

References: Documentation
     JavaServer Pages Specification Version 1.2 - DTD for TagLibrary Descriptor, JSP 1.2

Location: ... > Designing and Developing a Custom Tab Library > Objective 12.4 > Item 1
66. Which method of a Custom Tag handler class is NOT called by the JSP Implementation
class if the tag is an empty tag?

  A         release
  B         doEndTag
  C         doStartTag
  D         doAfterBody
Answer:
Option D is correct because the doAfterBody method is not called by the JSP Implementation
class if the tag is empty.
Options A, B, and C are incorrect because they are all called by the JSP Implementation class.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Tag Extension API - Simple Tag Handlers
     - IterationTag

Location: ... > Designing and Developing a Custom Tab Library > Objective 12.4 > Item 2
67. Which method is invoked when processing a custom tag handler in a JSP page to determine
whether to reevaluate the body?

  A         doBody
  B         doInitBody
  C         doAfterBody
  D         doEvaluateBody

Answer:
Option C is correct because the doAfterBody method is invoked to determine whether to
reevaluate the body.
Options A and D are incorrect because doBody and doEvaluateBody are not valid methods.
Option B is incorrect because the doInitBody is called before the body is evaluated.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Tag Extension API - Simple Tag Handlers
     - Tag

Location: ... > Designing and Developing a Custom Tab Library > Objective 12.5 > Item 1
68. Which two are valid return values for the doEndTag method of a custom tag class handler?
(Choose two.)

  A         SKIP_PAGE
  B         EVAL_PAGE
  C         SKIP_BODY
  D         EVAL_BODY_AGAIN
  E         EVAL_BODY_INCLUDE

Answer:
Options A and B are correct because SKIP_PAGE and EVAL_PAGE are valid return values
for the doEndTag method.
Options C, D, and E are incorrect because SKIP_BODY, EVAL_BODY_AGAIN, and
EVAL_BODY_INCLUDE are not valid return values for the doEndTag method.

References:  Documentation
     JavaServer Pages Specification Version 1.2 - Tag Extension API - Simple Tag Handlers
     - Tag
Location: ... > Designing and Developing a Custom Tab Library > Objective 12.6 > Item 1
69. Which value must the doEndTag method of a custom tag handler class return if the
remainder of the JSP page must continue to be evaluated?

  A         EVAL_PAGE
  B         EVAL_BODY
  C         EVAL_BODY_AGAIN
  D         EVAL_BODY_INCLUDE

Answer:
Option A is correct because the EVAL_PAGE value must be returned by the doEndTag
method to continue evaluating the rest of the page.
Options B, C, and D are incorrect because EVAL_BODY, EVAL_BODY_AGAIN, and
EVAL_BODY_INCLUDE are invalid return values for the doEndTag method.

References:  Documentation
     JavaServer Pages Specification Version 1.2 - Tag Extension API - Simple Tag Handlers
     - Tag

Location: ... > Designing and Developing a Custom Tab Library > Objective 12.7 > Item 1
70. Which method of the PageContext class can a tag handler class use to search for a named
attribute in all available scopes?

  A         findAttribute
  B         searchAttribute
  C         getAllScopeAttributes
  D         getAvailableAttributes

Answer:
Option A is correct because the findAttribute method can be used to search for a named
attribute in all available scopes.
Options B, C, and D are incorrect because searchAttribute, getAllScopeAttributes, and
getAvailableAttributes are not valid methods for PageContext.

References:  Documentation
     JavaServer Pages Specification Version 1.2 - Core API - Implicit Objects – PageContext

Location: ... > Designing and Developing a Custom Tab Library > Objective 12.8 > Item 1
71. Which method of the TagSupport class can be used by an inner tag handler to access an
outer tag handler that is not enclosing it immediately?

  A         findParent
  B         findParentWithClass
  C         getAncestorWithClass
  D         FindAncestorWithClass

Answer:
Option D is correct because the findAncestorWithClass method can be used to access an outer
tag handler.
Options A, B, and C are incorrect because findParent, findParentWithClass, and
getAncestorWithClass are not valid methods for the TagSupport class.

References: Documentation
     JavaServer Pages Specification Version 1.2 - Core API - Implicit Objects – PageContext

Location: ... > Design Patterns for Web Applications > Objective 13.1 > Item 1
72. You have been tasked with improving an existing Web application. The application has an
EJB application server with multiple clients talking over the network. The clients call various
methods of EJBs to obtain each of the EJB's data attributes. Which design pattern will allow
you to help reduce the network traffic?

   A         Factory
   B         Value Object
   C         Front Component
   D         Data Access Object

Answer:
Option B is correct. Value Object can package all the attributes needed from an EJB into a
single object. There will not be a need to go across the network.
Options A, C, and D are incorrect. Data Access Object simplifies database access, while Front
Component takes care of dispatching requests. A Factory is concerned with the creation of
objects.

References: Documentation
     J2EE Patterns - http://www.javasoft.com

Location: ... > Design Patterns for Web Applications > Objective 13.1 > Item 2
73. You are the new Java Architect of MyCompany.com. MyCompany.com uses LDAP to store
data for the organization. In the future when the budget is approved, Management wants to
migrate to an Oracle database for storing organizational data. The approval could take 2 years.
In the meantime, you are asked to develop a J2EE based solution to access the organizational
data. Which design pattern will allow you flexibility and transparency when the changeover to
the Oracle database occurs?

   A         Facade
   B         Value Object
   C         Business Delegate
   D         Data Access Object

Answer:
Option D is correct because Data Access Objects allow flexibility in accessing data.
Options A, B, and C are incorrect because Facade, Value Object, and Business Delegate do not
provide a simplified mechanism for accessing the database.

References: Documentation
     J2EE Patterns - http://www.javasoft.com

Location: ... > Design Patterns for Web Applications > Objective 13.2 > Item 1
74. Which three are benefits of using a Business Delegate pattern? (Choose three.)

   A         It improves performance by providing a caching service.
   B         It provides a simpler and more uniform interface to the clients.
   C         It ensures that there is only one instance of the Business Object.
   D         It reduces network traffic by encapsulating the attribute of a bean.
   E         It provides a loose coupling between the Presentation tier and the Business tier.

Answer:
Options A, B, and E are correct. A Business Delegate pattern improves performance by
providing a caching service, provides a simpler and more uniform interface to clients, and
provides a loose coupling between the Presentation and Business tiers.
Options C and D are incorrect because the Business Delegate pattern does not reduce network
traffic by encapsulating the attribute of a bean, nor does it ensure that there is only one
instance of the Business Object.

References: Documentation
     J2EE Patterns - http://www.javasoft.com

Location: ... > Design Patterns for Web Applications > Objective 13.2 > Item 2
75. Which pattern provides the benefit of plug-and-play between the data presentation and
data representation?

   A         Singleton
   B         Value Object
   C         Data Access Object
   D         Model View Controller

Answer:
Option D is correct because Model View Controller allows the Model and View plug-and-play
via the controller.
Options A, B, and C are incorrect because Singleton, Value Object, and Data Access Object do
not facilitate plug-and-play.

References: Documentation
     J2EE Patterns - http://www.javasoft.com

								
To top