Friday, 16 December 2011

SCWCD Questions 91- 100


QUESTION NO: 91


Assume the custom tag my:errorProne always throws a java.lang.RuntimeException with the
message "File not found."
An error page has been configured for this JSP page.
Which option prevents the exception thrown by my:errorProne from invoking the error page
mechanism, and outputs the message "File not found" in the response?
A. <c:try catch="ex">
<my:errorProne />
</c:try>
${ex.message}
B. <c:catch var="ex">
<my:errorProne />
</c:catch>
${ex.message}
C. <c:try>
<my:errorProne />
</c:try>
<c:catch var="ex" />
${ex.message}
D. <c:try>
<my:errorProne />
<c:catch var="ex" />
${ex.message}
</c:try>
E. <my:errorProne>
<c:catch var="ex">
${ex.message}
</c:catch>
</my:errorProne>

Answer: B

QUESTION NO: 92


A JSP page contains a taglib directive whose uri attribute has the value dbtags. Which XML
element within the web application deployment descriptor defines the associated TLD?
A. <tld>
<uri>dbtags</uri>
<location>/WEB-INF/tlds/dbtags.tld</location>
</tld>
B. <taglib>
<uri>dbtags</uri>
<location>/WEB-INF/tlds/dbtags.tld</location>
</taglib>
C. <tld>
<tld-uri>dbtags</tld-uri>
<tld-location>/WEB-INF/tlds/dbtags.tld</tld-location>
</tld>
D. <taglib>
<taglib-uri>dbtags</taglib-uri>
<taglib-location>
/WEB-INF/tlds/dbtags.tld
</taglib-location>
</taglib>

Answer: D


QUESTION NO: 93


Assume that a news tag library contains the tags lookup and item:
lookup Retrieves the latest news headlines and executes the tag body once for each headline.
Exposes a NESTED page-scoped attribute called headline of type com.example.Headline
containing details for that headline.
item Outputs the HTML for a single news headline. Accepts an attribute info of type
com.example.Headline containing details for the headline to be rendered.Which snippet of JSP
code returns the latest news headlines in an HTML table, one per row?
A. <table>
<tr>
<td>
<news:lookup />
<news:item info="${headline}" />
</td>
</tr>
</table>
B. <news:lookup />
<table>
<tr>
<td><news:item info="${headline}" /></td>
</tr>
</table>
C. <table>
<news:lookup>
<tr>
<td><news:item info="${headline}" /></td>
</tr>
</news:lookup>
</table>
D. <table>
<tr>
<news:lookup>
<td><news:item info="${headline}" /></td>
</news:lookup>
</tr>
</table>

Answer: C


QUESTION NO: 94


Click the Exhibit button.
Assuming the tag library in the exhibit is imported with the prefix stock, which custom tag
invocation outputs the contents of the variable exposed by the quote tag?

A. <stock:quote symbol="SUNW" />
${var}
B. ${var}
<stock:quote symbol="SUNW" />
C. <stock:quote symbol="SUNW">
${var}
</stock:quote>
D. <stock:quote symbol="SUNW" var="quote" />
${quote}
E. <stock:quote symbol="SUNW" var="quote">
<%= quote %>
</stock:quote>

Answer: D

QUESTION NO: 95

Which two are true about the JSTL core iteration custom tags? (Choose two.)
A. It may iterate over arrays, collections, maps, and strings.
B. The body of the tag may contain EL code, but not scripting code.
C. When looping over collections, a loop status object may be used in the tag body.
D. It may iterate over a map, but only the key of the mapping may be used in the tag body.
E. When looping over integers (for example begin='1' end='10'), a loop status object may not be
used in the tag body.

Answer: A,C

QUESTION NO: 96

Assume a JavaBean com.example.GradedTestBean exists and has two attributes. The attribute
name is of type java.lang.String and the attribute score is of type java.lang.Integer.
An array of com.example.GradedTestBean objects is exposed to the page in a request-scoped
attribute called results. Additionally, an empty java.util.HashMap called resultMap is placed in the
page scope.
A JSP page needs to add the first entry in results to resultMap, storing the name attribute of the
bean as the key and the score attribute of the bean as the value.
Which code snippet of JSTL code satisfies this requirement?
A. ${resultMap[results[0].name] = results[0].score}
B. <c:set var="${resultMap}" key="${results[0].name}"
value="${results[0].score}" />
C. <c:set var="resultMap" property="${results[0].name}">
${results[0].value}
</c:set>
D. <c:set var="resultMap" property="${results[0].name}"
value="${results[0].score}" />
E. <c:set target="${resultMap}" property="${results[0].name}"
value="${results[0].score}" />

Answer: E

QUESTION NO: 97

You are creating a JSP page to display a collection of data. This data can be displayed in several
different ways so the architect on your project decided to create a generic servlet that generates a
comma-delimited string so that various pages can render the data in different ways. This servlet
takes on request parameter: objectID. Assume that this servlet is mapped to the URL pattern:
/WEB-INF/data.
In the JSP you are creating, you need to split this string into its elements separated by commas
and generate an HTML <ul> list from the data.
Which JSTL code snippet will accomplish this goal?
A. <c:import varReader='dataString' url='/WEB-INF/data'>
<c:param name='objectID' value='${currentOID}' />
</c:import>
<ul>
<c:forTokens items'${dataString.split(",")}' var='item'>
<li>${item}</li>
</c:forTokens>
</ul>
B. <c:import varReader='dataString' url='/WEB-INF/data'>
<c:param name='objectID' value='${currentOID}' />
</c:import>
<ul>
<c:forTokens items'${dataString}' delims=',' var='item'>
<li>${item}</li>
</c:forTokens>
</ul>
C. <c:import var='dataString' url='/WEB-INF/data'>
<c:param name='objectID' value='${currentOID}' />
</c:import>
<ul>
<c:forTokens items'${dataString.split(",")}' var='item'>
<li>${item}</li>
</c:forTokens>
</ul>
D. <c:import var='dataString' url='/WEB-INF/data'>
<c:param name='objectID' value='${currentOID}' />
</c:import>
<ul>
<c:forTokens items'${dataString}' delims=',' var='item'>
<li>${item}</li>
</c:forTokens>
</ul>

Answer: D

QUESTION NO: 98

A web application contains a tag file called beta.tag in /WEB-INF/tags/alpha. A JSP page called
sort.jsp exists in the web application and contains only this JSP code:
1. <%@ taglib prefix="x"
2. tagdir="/WEB-INF/tags/alpha" %>
3. <x:beta />
The sort.jsp page is requested.
Which two are true? (Choose two.)
A. Tag files can only be accessed using a tagdir attribute.
B. The sort.jsp page translates successfully and invokes the tag defined by beta.tag.
C. The sort.jsp page produces a translation error because a taglib directive must always have a uri
attribute.
D. Tag files can only be placed in /WEB-INF/tags, and NOT in any subdirectories of /WEBINF/
tags.
E. The tagdir attribute in line 2 can be replaced by a uri attribute if a TLD referring to beta.tag is
created and added to the web application.
F. The sort.jsp page produces a translation error because the tagdir attribute on lines 1-2 specifies
a directory other than /WEB-INF/tags, which is illegal.

Answer: B,E

QUESTION NO: 99

What is the purpose of session management?
A. To manage the user's login and logout activities.
B. To store information on the client-side between HTTP requests.
C. To store information on the server-side between HTTP requests.
D. To tell the web container to keep the HTTP connection alive so it can make subsequent
requests without the delay of making the TCP connection.

Answer: C

QUESTION NO: 100

The Squeaky Beans Inc. shopping application was initially developed for a non-distributed
environment. The company recently purchased the Acme Application Server, which supports
distributed HttpSession objects. When deploying the application to the server, the deployer marks
it as distributable in the web application deployment descriptor to take advantage of this feature.
Given this scenario, which two must be true? (Choose two.)
A. The J2EE web container must support migration of objects that implement Serializable.
B. The J2EE web container must use the native JVM Serialization mechanism for distributing
HttpSession objects.
C. As per the specification, the J2EE web container ensures that distributed HttpSession objects
will be stored in a database.
D. Storing references to Enterprise JavaBeans components in the HttpSession object might NOT
be supported by J2EE web containers.

Answer: A,D


No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...