Friday 16 December 2011

SCWCD Questions 111- 120


QUESTION NO: 111


Which two are true about authentication? (Choose two.)
A. Form-based logins should NOT be used with HTTPS.
B. When using Basic Authentication the target server is NOT authenticated.
C. J2EE compliant web containers are NOT required to support the HTTPS protocol.
D. Web containers are required to support unauthenticated access to unprotected web resources.
E. Form-based logins should NOT be used when sessions are maintained by cookies or SSL
session information.

Answer: B,D


QUESTION NO: 112


Given:
11. <%
12. request.setAttribute("vals", new String[]{"1","2","3","4"});
13. request.setAttribute("index", "2");
14. %>
15. <%-- insert code here --%>
Which three EL expressions, inserted at line 15, are valid and evaluate to "3"? (Choose three.)
A. ${vals.2}
B. ${vals["2"]}
C. ${vals.index}
D. ${vals[index]}
E. ${vals}[index]
F. ${vals.(vals.index)}
G. ${vals[vals[index-1]]}

Answer: B,D,G


QUESTION NO: 113


Given:
11. <% java.util.Map map = new java.util.HashMap();
12. request.setAttribute("map", map);
13. map.put("a", "true");
14. map.put("b", "false");
15. map.put("c", "42"); %>
Which three EL expressions are valid and evaluate to true? (Choose three.)
A. ${not map.c}
B. ${map.d or map.a}
C. ${map.a and map.d}
D. ${map.false or map.true}
E. ${map.a and map.b or map.a}
F. ${map['true'] or map['false']}

Answer: A,B,E


QUESTION NO: 114


Given:
http://com.example/myServlet.jsp?num=one&num=two&num=three
Which two produce the output "one, two and three"? (Choose two.)
A. ${param.num[0],[1] and [2]}
B. ${paramValues[0],[1] and [2]}
C. ${param.num[0]}, ${param.num[1]} and ${param.num[2]}
D. ${paramValues.num[0]}, ${paramValues.num[1]} and ${paramValues.num[2]}
E. ${paramValues["num"][0]}, ${paramValues["num"][1]} and ${paramValues["num"][2]}
F. ${parameterValues.num[0]}, ${parameterValues.num[1]} and ${parameterValues.num[2]}
G. ${parameterValues["num"]["0"]}, ${parameterValues["num"]["1"]} and
${parameterValues["num"]["2"]}

Answer: D,E

QUESTION NO: 115


Given a web application in which the cookie userName is expected to contain the name of the
user. Which EL expression evaluates to that user name?
A. ${userName}
B. ${cookie.userName}
C. ${cookie.user.name}
D. ${cookies.userName[0]}
E. ${cookies.userName}[1]
F. ${cookies.get('userName')}

Answer: B


QUESTION NO: 116


Given an EL function declared with:
11. <function>
12. <name>spin</name>
13. <function-class>com.example.Spinner</function-class>
14. <function-signature>
15. java.lang.String spinIt()
16. </function-signature>
17. </function>
Which two are true? (Choose two.)
A. The function method must have the signature:
public String spin().
B. The method must be mapped to the logical name "spin" in the web.xml file.
C. The function method must have the signature:
public String spinIt().
D. The function method must have the signature
public static String spin().
E. The function method must have the signature:
public static String spinIt().
F. The function class must be named Spinner, and must be in the package com.example.

Answer: E,F

QUESTION NO: 117


Given a JSP page:
11. <n:recurse>
12. <n:recurse>
13. <n:recurse>
14. <n:recurse />
15. </n:recurse>
16. </n:recurse>
17. </n:recurse>
The tag handler for n:recurse extends SimpleTagSupport.
Assuming an n:recurse tag can either contain an empty body or another n:recurse tag, which
strategy allows the tag handler for n:recurse to output the nesting depth of the deepest n:recurse
tag?
A. It is impossible to determine the deepest nesting depth because it is impossible for tag handlers
that extend SimpleTagSupport to communicate with their parent and child tags.
B. Create a private non-static attribute in the tag handler class called count of type int initialized to
0. Increment count in the doTag method. If the tag has a body, invoke the fragment for that body.
Otherwise, output the value of count.
C. Start a counter at 1. Call getChildTags(). If it returns null, output the value of the counter.
Otherwise, increment counter and continue from where getChildTags() is called. Skip processing
of the body.
D. If the tag has a body, invoke the fragment for that body.Otherwise, start a counter at 1. Call
getParent(). If it returns null, output the value of the counter Otherwise, increment the counter and
continue from where getParent() is called.

Answer: D


QUESTION NO: 118


Click the Exhibit button.
The h:highlight tag renders its body, highlighting an arbitrary number of words, each of which is
passed as an attribute (word1, word2, ...). For example, a JSP page can invoke the h:highlight tag
as follows:

11. <h:highlight color="yellow" word1="high" word2="low">
12. high medium low
13. </h:highlight>
Given that HighlightTag extends SimpleTagSupport, which three steps are necessary to
implement the tag handler for the highlight tag? (Choose three).



A. add a doTag method
B. add a doStartTag method
C. add a getter and setter for the color attribute
D. create and implement a TagExtraInfo class
E. implement the DynamicAttributes interface
F. add a getter and setter for the word1 and word2 attributes

Answer: A,C,E

QUESTION NO: 119

Given:
5. public class MyTagHandler extends TagSupport {
6. public int doStartTag() throws JspException {
7. try {
8. // insert code here
9. } catch(Exception ex) { /* handle exception */ }
10. return super.doStartTag();
11. }
...
42. }
Which code snippet, inserted at line 8, causes the value foo to be output?
A. JspWriter w = pageContext.getOut();
w.print("foo");
B. JspWriter w = pageContext.getWriter();
w.print("foo");
C. JspWriter w = new JspWriter(pageContext.getWriter());
w.print("foo");
D. JspWriter w = new JspWriter(pageContext.getResponse());
w.print("foo");

Answer: A

QUESTION NO: 120

Given:
6. <myTag:foo bar='42'>
7. <%="processing" %>
8. </myTag:foo>
and a custom tag handler for foo which extends TagSupport.
Which two are true about the tag handler referenced by foo? (Choose two.)
A. The doStartTag method is called once.
B. The doAfterBody method is NOT called.
C. The EVAL_PAGE constant is a valid return value for the doEndTag method.
D. The SKIP_PAGE constant is a valid return value for the doStartTag method.
E. The EVAL_BODY_BUFFERED constant is a valid return value for the doStartTag method.

Answer: A,C



No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...