Monday, January 5, 2015

SCWCD Questions And Answers Part 3

Q: 61 You are creating a web form with this HTML:

11. <form action="sendOrder.jsp">
12. <input type="text" name="creditCard">
13. <input type="text" name="expirationDate">
14. <input type="submit">
15. </form>


Which HTTP method is used when sending this request from the browser?

A. GET
B. PUT
C. POST
D. SEND
E. FORM

Answer: A


Q: 62 Given an HttpSession session, a ServletRequest request, and a ServletContext context, which retrieves a URL to /WEB-INF/myconfig.xml within a web application? 

A. session.getResource("/WEB-INF/myconfig.xml")
B. request.getResource("/WEB-INF/myconfig.xml")
C. context.getResource("/WEB-INF/myconfig.xml")
D. getClass().getResource("/WEB-INF/myconfig.xml")

Answer: C


Q: 63 Your company has a corporate policy that prohibits storing a customer's credit card number in any corporate database. However, users have complained that they do NOT want to re-enter their credit card number for each transaction. Your management has decided to use client-side cookies to record the user's credit card number for 120 days. Furthermore, they also want to protect this information during transit from the web browser to the web container; so the cookie must only be transmitted over HTTPS.

Which code snippet creates the "creditCard" cookie and adds it to the out going response to be stored on the user's web browser?

A. 10. Cookie c = new Cookie("creditCard", usersCard);
11. c.setSecure(true);
12. c.setAge(10368000);
13. response.addCookie(c);
B. 10. Cookie c = new Cookie("creditCard", usersCard);
11. c.setHttps(true);
12. c.setMaxAge(10368000);
13. response.setCookie(c);
C. 10. Cookie c = new Cookie("creditCard", usersCard);
11. c.setSecure(true);
12. c.setMaxAge(10368000);
13. response.addCookie(c);
D. 10. Cookie c = new Cookie("creditCard", usersCard);
11. c.setHttps(true);
12. c.setAge(10368000);
13. response.addCookie(c);
E. 10. Cookie c = new Cookie("creditCard", usersCard);
11. c.setSecure(true);
12. c.setAge(10368000);
13. response.setCookie(c);

Answer: C


Q: 64 Given a header in an HTTP request: X-Retries: 4

Which two retrieve the value of the header from a given HttpServletRequest request? (Choose two.)

A. request.getHeader("X-Retries")
B. request.getIntHeader("X-Retries")
C. request.getRequestHeader("X-Retries")
D. request.getHeaders("X-Retries").get(0)
E. request.getRequestHeaders("X-Retries").get(0)

Answer: A, B


Q: 65 For a given ServletResponse response, which two retrieve an object for writing text data? (Choose two.) 

A. response.getWriter()
B. response.getOutputStream()
C. response.getOutputWriter()
D. response.getWriter().getOutputStream()
E. response.getWriter(Writer.OUTPUT_TEXT)

Answer: A, B


Q: 66 Which JSP standard action can be used to import content from a resource called foo.jsp? 

A. <jsp:import file='foo.jsp' />
B. <jsp:import page='foo.jsp' />
C. <jsp:include page='foo.jsp' />
D. <jsp:include file='foo.jsp' />
E. <jsp:import>foo.jsp</jsp:import>
F. <jsp:include>foo.jsp</jsp:include>

Answer: C


Q: 67 Click the Task button.

A servlet context listener loads a list of com.example.Product objects from a database and stores that list into the catalog attribute of the ServletContext object.
Place code snippets to construct a jsp:useBean standard action to access this catalog.


Answer: Check ExamWorx eEngine, Download from Member Center


Q: 68 A session-scoped attribute is stored by a servlet, and then that servlet forwards to a JSP page. Which three jsp:useBean attributes must be used to access this attribute in the JSP page? (Choose three.)

A. id
B. name
C. bean
D. type
E. scope
F. beanName

Answer: A, D, E


Q: 69 You need to create a JavaBean object that is used only within the current JSP page. It must NOT be accessible to any other page including those that this page might import. Which JSP standard action can accomplish this goal?

A. <jsp:useBean id='pageBean' type='com.example.MyBean' />
B. <jsp:useBean id='pageBean' class='com.example.MyBean' />
C. <jsp:makeBean id='pageBean' type='com.example.MyBean' />
D. <jsp:makeBean id='pageBean' class='com.example.MyBean' />
E. <jsp:useBean name='pageBean' class='com.example.MyBean' />
F. <jsp:makeBean name='pageBean' class='com.example.MyBean' />

Answer: B


Q: 70 Given an HttpServletRequest request and HttpServletResponse response, which sets a cookie "username" with the value "joe" in a servlet?

A. request.addCookie("username", "joe")
B. request.setCookie("username", "joe")
C. response.addCookie("username", "joe")
D. request.addHeader(new Cookie("username", "joe"))
E. request.addCookie(new Cookie("username", "joe"))
F. response.addCookie(new Cookie("username", "joe"))
G. response.addHeader(new Cookie("username", "joe"))

Answer: F


Q: 71 Your web page includes a Java SE v1.5 applet with the following declaration:

11. <object classid='clsid:CAFEEFAC-0015-0000-0000-ABCDEFFEDCBA'
12. width='200' height='200'>
13. <param name='code' value='Applet.class' />
14. </object>


Which HTTP method is used to retrieve the applet code?

A. GET
B. PUT
C. POST
D. RETRIEVE

Answer: A


Q: 72 You are creating a servlet that generates stock market graphs. You want to provide the web browser with precise information about the amount of data being sent in the response stream. Which two HttpServletResponse methods will you use to provide this information? (Choose two.)
  
A. response.setLength(numberOfBytes);
B. response.setContentLength(numberOfBytes);
C. response.setHeader("Length", numberOfBytes);
D. response.setIntHeader("Length", numberOfBytes);
E. response.setHeader("Content-Length", numberOfBytes);
F. response.setIntHeader("Content-Length", numberOfBytes);

Answer: B, F


Q: 73 You need to retrieve the username cookie from an HTTP request. If this cookie does NOT exist, then the c variable will be null. Which code snippet must be used to retrieve this cookie object?

A. 10. Cookie c = request.getCookie("username");
B. 10. Cookie c = null;
11. for ( Iterator i = request.getCookies();
12. i.hasNext(); ) {
13. Cookie o = (Cookie) i.next();
14. if ( o.getName().equals("username") ) {
15. c = o;
16. break;
17. }
18. }
C. 10. Cookie c = null;
11. for ( Enumeration e = request.getCookies();
12. e.hasMoreElements(); ) {
13. Cookie o = (Cookie) e.nextElement();
14. if ( o.getName().equals("username") ) {
15. c = o;
16. break;
17. }
18. }
D. 10. Cookie c = null;
11. Cookie[] cookies = request.getCookies();
12. for ( int i = 0; i < cookies.length; i++ ) {
13. if ( cookies[i].getName().equals("username") ) {
14. c = cookies[i];
15. break;
16. }
17. }

Answer: D


Q: 74 Given:

10. public void service(ServletRequest request,
11. ServletResponse response) {
12. ServletInputStream sis =
13. // insert code here
14. }


Which retrieves the binary input stream on line 13?

A. request.getWriter();
B. request.getReader();
C. request.getInputStream();
D. request.getResourceAsStream();
E. request.getResourceAsStream(ServletRequest.REQUEST);

Answer: C


Q: 75 Click the Exhibit button.
As a maintenance feature, you have created this servlet to allow you to upload and remove files on your web server. Unfortunately, while testing this servlet, you try to upload a file using an HTTP request and on this servlet, the web container returns a 404 status.

What is wrong with this servlet?


A. HTTP does NOT support file upload operations.
B. The servlet constructor must NOT have any parameters.
C. The servlet needs a service method to dispatch the requests to the helper methods.
D. The doPut and doDelete methods do NOT map to the proper HTTP methods.

Answer: B


Q: 76 You have built a web application with tight security. Several directories of your webapp are used for internal purposes and you have overridden the default servlet to send an HTTP 403 status code for any request that maps to one of these directories. During testing, the Quality Assurance director decided that they did NOT like seeing the bare response page generated by Firefox and Internet Explorer. The director recommended that the webapp should return a more user-friendly web page that has the same look-and-feel as the webapp plus links to the webapp's search engine. You have created this JSP page in the /WEB-INF/jsps/error403.jsp file. You do NOT want to alter the complex logic of the default servlet. How can you declare that the web container must send this JSP page whenever a 403 status is generated?

A. <error-page> <error-code>403</error-code> <url>/WEB-INF/jsps/error403.jsp</url> </error-page>
B. <error-page> <status-code>403</status-code> <url>/WEB-INF/jsps/error403.jsp</url> </error-page>
C. <error-page> <error-code>403</error-code>
<location>/WEB-INF/jsps/error403.jsp</location> </error-page>
D. <error-page> <status-code>403</status-code> <location>/WEB-INF/jsps/error403.jsp</location> </error-page>

 Answer: C


Q: 77 You want to create a valid directory structure for your Java EE web application, and your application uses tag files and a JAR file. Which three must be located directly in your WEB-INF directory (NOT in a subdirectory of WEB-INF)? (Choose three.)

A. The JAR file
B. A directory called lib
C. A directory called tags
D. A directory called TLDs
E. A directory called classes
F. A directory called META-INF

Answer: B, C, E


Q: 78 Given:



11. public class MyServlet extends HttpServlet {
12. public void service(HttpServletRequest request,
13. HttpServletResponse response)
14. throws ServletException, IOException {
15. // insert code here
16. }
17. }


and this element in the web application's deployment descriptor:
<error-page> <error-code>302</error-code> <location>/html/error.html</location> </error-page>

Which, inserted at line 15, causes the container to redirect control to the error.html resource?

A. response.setError(302);
B. response.sendError(302);
C. response.setStatus(302);
D. response.sendRedirect(302);
E. response.sendErrorRedirect(302);

Answer: B


Q: 79 Which element of the web application deployment descriptor defines the servlet class associated with a servlet instance?

A. <class>
B. <webapp>
C. <servlet>
D. <codebase>
E. <servlet-class>
F. <servlet-mapping>

Answer: E


Q: 80 Within the web application deployment descriptor, which defines a valid JNDI environment entry?

A. <env-entry> <env-entry-type>java.lang.Boolean</env-entry-type> <env-entry-value>true</env-entry-value> </env-entry>
B. <env-entry> <env-entry-name>param/MyExampleString</env-entry-name> <env-entry-value>This is an Example</env-entry-value> </env-entry>
C. <env-entry> <env-entry-name>param/MyExampleString</env-entry-name> <env-entry-type>int</env-entry-type> <env-entry-value>10</env-entry-value>
</env-entry>
D. <env-entry>
<env-entry-name>param/MyExampleString</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>This is an Example</env-entry-value> </env-entry>

Answer: D


Q: 81 Which three are described in the standard web application deployment descriptor? (Choose three.) 

A. session configuration
B. MIME type mappings
C. context root for the application
D. servlet instance pool configuration
E. web container default port bindings
F. ServletContext initialization parameters

Answer: A, B, F


Q: 82 Which two are true regarding a web application class loader? (Choose two.)

A. A web application may override the web container's implementation classes.
B. A web application running in a J2EE product may override classes in the javax.* namespace.
C. A web application class loader may NOT override any classes in the java.* and javax.* namespaces.
D. Resources in the WAR class directory or in any of the JAR files within the library directory may be accessed using the J2SE semantics of getResource.
E. Resources in the WAR class directory or in any of the JAR files within the library directory CANNOT be accessed using the J2SE semantics of getResource.

Answer: C, D


Q: 83 Click the Task button.

Place the corresponding resources and directories in the proper web application deployment structure.


Answer: Check ExamWorx eEngine, Download from Member Center


Q: 84 You are building JSP pages that have a set of menus that are visible based on a user's security role. These menus are hand-crafted by your web design team; for example, the SalesManager role has a menu in the file /WEB-INF/html/sales-mgr-menu.html. Which JSP code snippet should be used to make this menu visible to the user?

A. <% if ( request.isUserInRole("SalesManager") ) { %> <%@ include file='/WEB-INF/html/sales-mgr-menu.html' %> <% } %>
B. <jsp:if test='request.isUserInRole("SalesManager")'> <%@ include file='/WEB-INF/html/sales-mgr-menu.html' %> </jsp:if>
C. <% if ( request.isUserInRole("SalesManager") ) { %> <jsp:include file='/WEB-INF/html/sales-mgr-menu.html' /> <% } %>
D. <jsp:if test='request.isUserInRole("SalesManager")'> <jsp:include file='/WEB-INF/html/sales-mgr-menu.html' /> </jsp:if>

Answer: A


Q: 85 For debugging purposes, you need to record how many times a given JSP is invoked before the user's session has been created. The JSP's destroy method stores this information to a database. Which JSP code snippet keeps track of this count for the lifetime of the JSP page?

A. <%! int count = 0; %>
<% if ( request.getSession(false) == null ) count++; %>
B. <%@ int count = 0; %>
<% if ( request.getSession(false) == null ) count++; %>
C. <% int count = 0;
if ( request.getSession(false) == null ) count++; %>
D. <%@ int count = 0;
if ( request.getSession(false) == null ) count++; %>
E. <%! int count = 0;
if ( request.getSession(false) == null ) count++; %>

Answer: A


Q: 86 For manageability purposes, you have been told to add a "count" instance variable to a critical JSP Document so that a JMX MBean can track how frequent this JSP is being invoked. Which JSP code snippet must you use to declare this instance variable in the JSP Document?

A. <jsp:declaration> int count = 0; <jsp:declaration>
B. <%! int count = 0; %>
C. <jsp:declaration.instance> int count = 0; <jsp:declaration.instance>
D. <jsp:scriptlet.declaration> int count = 0; <jsp:scriptlet.declaration>

Answer: A


Q: 87 In a JSP-centric web application, you need to create a catalog browsing JSP page. The catalog is stored as a List object in the catalog attribute of the webapp's ServletContext object. Which scriptlet code snippet gives you access to the catalog object?

A. <% List catalog = config.getAttribute("catalog"); %>
B. <% List catalog = context.getAttribute("catalog"); %>
C. <% List catalog = application.getAttribute("catalog"); %>
D. <% List catalog = servletContext.getAttribute("catalog"); %>

Answer: C


Q: 88 Given the element from the web application deployment descriptor:

<jsp-property-group> <url-pattern>/main/page1.jsp</url-pattern> <scripting-invalid>true</scripting-invalid> </jsp-property-group>
and given that /main/page1.jsp contains:

<% int i = 12; %> <b><%= i %></b>


What is the result?

A. <b></b>
B. <b>12</b>
C. the JSP fails to execute.
D. <% int i = 12 %> <b><%= i %></b>

Answer: C


Q: 89 You are creating a new JSP page and you need to execute some code that acts when the page is first executed, but only once. Which three are possible mechanisms for performing this initialization code? (Choose three.)

A. In the init method.
B. In the jspInit method.
C. In the constructor of the JSP's Java code.
D. In a JSP declaration, which includes an initializer block.
E. In a JSP declaration, which includes a static initializer block.

Answer: B, D, E


Q: 90 You are writing a JSP that includes scriptlet code to declare a List variable and initializes that variable to an ArrayList object. Which two JSP code snippets can you use to import these list types? (Choose two.)

A. <%! import java.util.*; %>
B. <%! import java.util.List; import java.util.ArrayList; %>
C.<%@page import='java.util.List' import='java.util.ArrayList' %>
D.<%@import types='java.util.List' types='java.util.ArrayList' %>
E. <%@ page import='java.util.List,java.util.ArrayList' %>
F. <%@ import types='java.util.List,java.util.ArrayList' %>

Answer: C, E

4 comments :

  1. Reserve Bank of India (RBI) has launched IFSC codes which stand for Indian Financial System Code.
    IFSC Code of IDBI Bank, Coimbatore
    IDBI (Industrial Development Bank of India) is a government-owned financial service company which was established in 1964 and it offers banking and financial solutions in the retail and corporate banking arena.

    ReplyDelete