Upwork JSP 2.0 Test 2016
45 Answered Test Questions:
1. If cookies are turned off on the client, which two methods still work with the session ID?
Answers:
a. response.getSessionId()
a. encodeRedirectURL()
a. sessionRedirectURL()
a. encodeURL()
2. Which two of the following statements are best associated with the HTTPPOST method?
Answers:
a. This HTTP method is the one most frequently used by browsers
a. There is no limit on how much data this HTTP method can send
a. There is a limit on how much data this HTTP method can send
a. This method is most often used to submit form data
3. Which two statements among the following apply to redirecting a HTTP request to another URL?
Answers:
a. The path must be absolute
a. The path must be relative
a. The redirect method must be called before the response body is committed, otherwise an IllegalStateException is thrown
a. The path may be relative or absolute
4. Which of the following statements are true regarding the HTTP GET method?
Answers:
a. There is a limit on how much data this HTTP method can send
a. There is no limit on how much data this HTTP method can send
a. This HTTP method is the fastest
a. This HTTP method is used when you click on an HTML link
5. Which of the following statements are true regarding declaring a servlet instance in a deployment descriptor?
Answers:
a. The tags are nested within tags
a. The tags do not define parameters
a. The tags are
a. It specifies the fully qualified class name of the servlet
6. Which of the following statements are true regarding the structure of a WebArchive file?
Answers:
a. It has a jar extension
a. It is a JAR archive of the WebApplication structure
a. It has a war extension
a. It is extracted by the container upon the first call to any�servlet it contains
7. With regard to the service() lifecycle method, identify two correct statements about its purpose or about how and when it is invoked.
Answers:
a. Upon completion it calls the destroy method
a. It is called whenever the servlet is requested
a. It is called after the init method is called
a. It is only called when the servlet is first requested
8. Read the following code snippet and answer the question based upon it:
1. If cookies are turned off on the client, which two methods still work with the session ID?
Answers:
a. response.getSessionId()
a. encodeRedirectURL()
a. sessionRedirectURL()
a. encodeURL()
2. Which two of the following statements are best associated with the HTTPPOST method?
Answers:
a. This HTTP method is the one most frequently used by browsers
a. There is no limit on how much data this HTTP method can send
a. There is a limit on how much data this HTTP method can send
a. This method is most often used to submit form data
3. Which two statements among the following apply to redirecting a HTTP request to another URL?
Answers:
a. The path must be absolute
a. The path must be relative
a. The redirect method must be called before the response body is committed, otherwise an IllegalStateException is thrown
a. The path may be relative or absolute
4. Which of the following statements are true regarding the HTTP GET method?
Answers:
a. There is a limit on how much data this HTTP method can send
a. There is no limit on how much data this HTTP method can send
a. This HTTP method is the fastest
a. This HTTP method is used when you click on an HTML link
5. Which of the following statements are true regarding declaring a servlet instance in a deployment descriptor?
Answers:
a. The tags are nested within tags
a. The tags do not define parameters
a. The tags are
a. It specifies the fully qualified class name of the servlet
6. Which of the following statements are true regarding the structure of a WebArchive file?
Answers:
a. It has a jar extension
a. It is a JAR archive of the WebApplication structure
a. It has a war extension
a. It is extracted by the container upon the first call to any�servlet it contains
7. With regard to the service() lifecycle method, identify two correct statements about its purpose or about how and when it is invoked.
Answers:
a. Upon completion it calls the destroy method
a. It is called whenever the servlet is requested
a. It is called after the init method is called
a. It is only called when the servlet is first requested
8. Read the following code snippet and answer the question based upon it:
http://www.yourcompany.com/you TagLibrary
/WEB-INF/yourTagLibrary.tld
From the statements given below, which one applies to the code snippet?
Answers:
a. The taglib directive can reference a TLD by name
a. This tag goes into the WEB-INF/myApplication/web.xml file
a. This definition is incorrect because the taglib-uri should have been uri
a. This definition is incorrect because the taglib should have been tag
9. Which method is called by the servlet container just after the servlet is removed from service?
Answers:
a. public void finalize() {// code…}
a. public void destroy() {// code…}
a. public void destroy()throws ServletException {// code…}
a. public void finalize()throws ServletException {// code…}
10. Which statement is true regarding ServletContext Initialization Parameters in the deployment descriptor?
Answers:
a. They are accessible by all servlets in a given web application
a. They are accessible by all servlets in a given session
a. They are accessible by all servlets in a given HTTP request
a. They are accessible by all servlets in a given container
11. Which method in the HttpServlet class corresponds to the HTTPPOST method?
Answers:
a. postHttp
a. doPost
a. post
a. getPost
12. What is the file name of the WebApp deployment descriptor?
Answers:
a. web.xml
a. deploy.xml
a. init.xml
a. config.xml
13. What is the WebApp deployment descriptor element name for the Servlet Context Initialization Parameters?
Answers:
a.
a.
a.
a.
14. With regard to the destroy lifecycle method, identify the correct statements about its purpose or about how and when it is invoked.
Answers:
a. It gives the servlet an opportunity to clean up resources
a. Like try-catch, it is called upon an exception
a. It is rarely used but can be called to remove a servlet from memory
a. It isn’t called if the server crashes
15. How would you use a bean in a JSP page?
Answers:
a.
a.
a.
a.
16. Which of the following is the name of the cookie used by Servlet Containers to maintain
session information?
Answers:
a. SESSIONID
a. SERVLETID
a. JSESSIONID
a. CONTAINERID
17. Which design pattern reduces network traffic by acting as a caching proxy of a remote object?
Answers:
a. DataAccess Object
a. Model-View-Controller
a. Value Object
a. Business Delegate
18. Assuming the tag library is in place and the tag handler is correct, which of the following is the correct way to use a custom tag in a JSP page?
Answers:
a. <yourLibrary=”whatColorlslt” color=”red”/>
a.
a.
a.
19. What output will be sent to the browser by the following code snippet?
From the statements given below, which one applies to the code snippet?
Answers:
a. The taglib directive can reference a TLD by name
a. This tag goes into the WEB-INF/myApplication/web.xml file
a. This definition is incorrect because the taglib-uri should have been uri
a. This definition is incorrect because the taglib should have been tag
9. Which method is called by the servlet container just after the servlet is removed from service?
Answers:
a. public void finalize() {// code…}
a. public void destroy() {// code…}
a. public void destroy()throws ServletException {// code…}
a. public void finalize()throws ServletException {// code…}
10. Which statement is true regarding ServletContext Initialization Parameters in the deployment descriptor?
Answers:
a. They are accessible by all servlets in a given web application
a. They are accessible by all servlets in a given session
a. They are accessible by all servlets in a given HTTP request
a. They are accessible by all servlets in a given container
11. Which method in the HttpServlet class corresponds to the HTTPPOST method?
Answers:
a. postHttp
a. doPost
a. post
a. getPost
12. What is the file name of the WebApp deployment descriptor?
Answers:
a. web.xml
a. deploy.xml
a. init.xml
a. config.xml
13. What is the WebApp deployment descriptor element name for the Servlet Context Initialization Parameters?
Answers:
a.
a.
a.
a.
14. With regard to the destroy lifecycle method, identify the correct statements about its purpose or about how and when it is invoked.
Answers:
a. It gives the servlet an opportunity to clean up resources
a. Like try-catch, it is called upon an exception
a. It is rarely used but can be called to remove a servlet from memory
a. It isn’t called if the server crashes
15. How would you use a bean in a JSP page?
Answers:
a.
a.
a.
a.
16. Which of the following is the name of the cookie used by Servlet Containers to maintain
session information?
Answers:
a. SESSIONID
a. SERVLETID
a. JSESSIONID
a. CONTAINERID
17. Which design pattern reduces network traffic by acting as a caching proxy of a remote object?
Answers:
a. DataAccess Object
a. Model-View-Controller
a. Value Object
a. Business Delegate
18. Assuming the tag library is in place and the tag handler is correct, which of the following is the correct way to use a custom tag in a JSP page?
Answers:
a. <yourLibrary=”whatColorlslt” color=”red”/>
a.
a.
a.
19. What output will be sent to the browser by the following code snippet?
Answers:
a. ‘Que Reader’ within HTML comment markers
a. This will cause an error
a. Que <%=”Reader”%> within HTML comment markers
a. This is a comment so it is ignored by the container
20. Which of the following are used by Servlet Containers to maintain session information?
Answers:
a. Cookies
a. Hidden form fields
a. HTTPS protocol information
a. URL rewriting
21. Read the following code snippet:
1 2 <%=23*counter %>
3 Congratulations!
3 Congratulations!
Which of the following is the correct way to complete the above code snippet?
Answers:
a.
a. a.
a. 22. In which directory do you place any auxiliary JAR files?
Answers:
a. WEB-INF/servlets
a. WEB-INF/jar
a. WEB-INF/classes
a. WEB-INF/lib
23. Which statements are true regarding ServletContext Init Parameters in the deployment descriptor?
Answers:
a. They are set at deployment-time, but accessed at run-time
a. They are accessible from any session within that context
a. They are not set at deployment-time, but accessed at run-time
a. They are set at deployment-time and can be updated at run-time
24. With regard to the servlet context listener, which of the following methods is valid?
Answers:
a. contextListenerEvent
a. contextListenerInitialized
a. contextInitialized
a. contextListenerDestroyed
25. Assuming the servlet method for handling HTTPGET requests is doGet(HttpServletRequest req, HTTPServletResponse res), how do you get a request parameter in that servlet?
Answers:
a. String value=req.getInitParameter(10);
a. String value=req.getInitParameter(“product”);
a. String value=res.getParameter(“product”);
a. String value=req.getParameter(“product”);
26. Assume the custom tag is GLOOP and the prefix is TWONG. Which of the following is the syntax for an empty custom tag?
Answers:
a.
a.
a.
a.
27. Which of the following is not a JSP implicit object?
Answers:
a. out
a. in
a. response
a. page
28. Which of the following is the listener interface for servlet context attributes?
Answers:
a. ContextAttributeListener
a. ServletContextAttributeListener
a. ServletAttributeListener
a. ServletContextListener
29. What is Template Data?
Answers:
a. The JSP blueprint or pattern
a. The plain text (such as HTML) outside JSP tags(non java) in a JSP page
a. The taglib XML namespace
30. Which of the following options is a valid declaration?
Answers:
a. <%! String name=”Patricia” %>
a. <%! String name=”Patricia”; %>
a. <% String name=”Devyn” %>
a. <% public String name=”Devyn”; %>
31. Which of following interfaces can make a servlet thread safe?
Answers:
a. Runnable
a. synchronization
a. Servlets can’t be made thread safe
a. None of the above
32. Which statement is true regarding a servlet context listener?
Answers:
a. An object that implements a context listener is notified when its request objects are created or destroyed
a. An object that implements a context listener is notified when its Web App context is created or destroyed
a. An object that implements a context listener is notified when its Web App deployment descriptor defines it to be notified
a. An object that implements a context listener is notified when its sessions are created or destroyed
33. Which of the following options is a valid expression?
Answers:
a. <%! String name=”Patricia” %>
a. <%! String name=”Patricia”; %>
a. <%=(new java.util.Date()).toLocaleString() %>
a. <% public String name=”Devyn”; %>
34. What does the container do with the following code snippet?
Answers:
a.
a. a.
a. 22. In which directory do you place any auxiliary JAR files?
Answers:
a. WEB-INF/servlets
a. WEB-INF/jar
a. WEB-INF/classes
a. WEB-INF/lib
23. Which statements are true regarding ServletContext Init Parameters in the deployment descriptor?
Answers:
a. They are set at deployment-time, but accessed at run-time
a. They are accessible from any session within that context
a. They are not set at deployment-time, but accessed at run-time
a. They are set at deployment-time and can be updated at run-time
24. With regard to the servlet context listener, which of the following methods is valid?
Answers:
a. contextListenerEvent
a. contextListenerInitialized
a. contextInitialized
a. contextListenerDestroyed
25. Assuming the servlet method for handling HTTPGET requests is doGet(HttpServletRequest req, HTTPServletResponse res), how do you get a request parameter in that servlet?
Answers:
a. String value=req.getInitParameter(10);
a. String value=req.getInitParameter(“product”);
a. String value=res.getParameter(“product”);
a. String value=req.getParameter(“product”);
26. Assume the custom tag is GLOOP and the prefix is TWONG. Which of the following is the syntax for an empty custom tag?
Answers:
a.
a.
a.
a.
27. Which of the following is not a JSP implicit object?
Answers:
a. out
a. in
a. response
a. page
28. Which of the following is the listener interface for servlet context attributes?
Answers:
a. ContextAttributeListener
a. ServletContextAttributeListener
a. ServletAttributeListener
a. ServletContextListener
29. What is Template Data?
Answers:
a. The JSP blueprint or pattern
a. The plain text (such as HTML) outside JSP tags(non java) in a JSP page
a. The taglib XML namespace
30. Which of the following options is a valid declaration?
Answers:
a. <%! String name=”Patricia” %>
a. <%! String name=”Patricia”; %>
a. <% String name=”Devyn” %>
a. <% public String name=”Devyn”; %>
31. Which of following interfaces can make a servlet thread safe?
Answers:
a. Runnable
a. synchronization
a. Servlets can’t be made thread safe
a. None of the above
32. Which statement is true regarding a servlet context listener?
Answers:
a. An object that implements a context listener is notified when its request objects are created or destroyed
a. An object that implements a context listener is notified when its Web App context is created or destroyed
a. An object that implements a context listener is notified when its Web App deployment descriptor defines it to be notified
a. An object that implements a context listener is notified when its sessions are created or destroyed
33. Which of the following options is a valid expression?
Answers:
a. <%! String name=”Patricia” %>
a. <%! String name=”Patricia”; %>
a. <%=(new java.util.Date()).toLocaleString() %>
a. <% public String name=”Devyn”; %>
34. What does the container do with the following code snippet?
Answers:
a. The container passes this line of code through to the client
a. The container includes this file statically
a. The container includes this file dynamically
a. The container will throw an exception
35. Which method in the HttpServlet class corresponds to the HTTPPUT method?
Answers:
a. put
a. doPut
a. httpPut
a. putHttp
36. Which of the following is a JSP implicit object?
Answers:
a. objRequest
a. Request.send
a. request
a. servlet
37. Which design pattern is used to decouple presentation from core data access functionality?
Answers:
a. BusinessDelegate
a. DataAccess Object
a. ModelView Controller
a. Value Object
38. In which directory do you place servlet class files?
Answers:
a. WEB-INF\servlets
a. webapp\servlets
a. WEB-INF\classes
a. WEB-INF\
39. Which design pattern did technical designers of JSP use to provide centralized dispatching of requests via a controller servlet?
Answers:
a. Model-view-Controller
a. Facade
a. Server-Client
a. Publish-Subscribe
40. Which interface and method name should be used to retrieve HTTP request header information?
Answers:
a. HttpServletRequest.getHeaderNames
a. ServletRequest.getNames
a. ServletRequest.getHeadNames
a. None of the above
41. Which interface provides access to request scoped attributes?
Answers:
a. ServletContext
a. ServletRequest
a. ServletConfig
a. None of these
42. Which JSP action retrieves the value of a property from a properly declared JavaBean in a JSP page?
Answers:
a. jsp:getProperty
a. jsp:getParameter
a. jsp:getAtrribute
a. jsp:getValue
43. Suppose you had a servlet that simply returned an error message because that resource was forbidden to that user. Read the following code snippet:
1.public void service(HttpServletRequestrequest,
2.HttpServletResponseresponse)
3.throws ServletException, IOException
4. {
5.
6. }
2.HttpServletResponseresponse)
3.throws ServletException, IOException
4. {
5.
6. }
What code would you type on line 5 to return an error message to the requesting client?
Answers:
a. response.sendError(HTTPServletResponse.SC_FORBIDDEN,”Error”);
a. response.setStatus(HTTPServletResponse.SC_FORBIDDEN,”Error”);
a. response.sendError(Response.SC_FORBIDDEN,”Error”);
a. response.setStatus(SC_FORBIDDEN);
44. Which interface and method name should be used to acquire a text stream for the response?
Answers:
a. ServletResponse.getOutputStream
a. ServletResponse.getWriterStream
a. ServletResponse.getTextStream
a. ServletResponse.getWriter
45. Which among the following objects is the best choice to share information between pages for a single user?
Answers:
a. application
a. page
a. request
a. session
Answers:
a. response.sendError(HTTPServletResponse.SC_FORBIDDEN,”Error”);
a. response.setStatus(HTTPServletResponse.SC_FORBIDDEN,”Error”);
a. response.sendError(Response.SC_FORBIDDEN,”Error”);
a. response.setStatus(SC_FORBIDDEN);
44. Which interface and method name should be used to acquire a text stream for the response?
Answers:
a. ServletResponse.getOutputStream
a. ServletResponse.getWriterStream
a. ServletResponse.getTextStream
a. ServletResponse.getWriter
45. Which among the following objects is the best choice to share information between pages for a single user?
Answers:
a. application
a. page
a. request
a. session
No comments:
Post a Comment