Friday 16 December 2011

SCWCD Questions 81- 90


QUESTION NO: 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


QUESTION NO: 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


QUESTION NO: 83 DRAG DROP


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

Answer:


QUESTION NO: 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

QUESTION NO: 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

QUESTION NO: 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

QUESTION NO: 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

QUESTION NO: 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

QUESTION NO: 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

QUESTION NO: 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


No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...