File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Question regarding answers in HFSJ 2nd ed mock exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Question regarding answers in HFSJ 2nd ed mock exam" Watch "Question regarding answers in HFSJ 2nd ed mock exam" New topic
Author

Question regarding answers in HFSJ 2nd ed mock exam

Marlo Magpantay
Greenhorn

Joined: Sep 15, 2010
Posts: 15
Hi,

I just like to confirm 2 items in HFSJ 2nd edition mock exam. Thanks in advance for your comments.

#26 - Answers in the book are B and D. Are they really the correct answers? But the comments in the book say otherwise.
Given:
01. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
02.
03. <%
04. java.util.List books = new java.util.ArrayList();
05. // add line here
06. request.setAttribute("myFavoriteBooks", books);
07. %>
08.
09. <c:choose>
10. <c:when test="${not empty myFavoriteBooks}">
11. My favorite books are:
12. <c:forEach var="book" items="${myFavoriteBooks}">
13. <br/> * ${book}
14. </c:forEach>
15. </c:when>
16. <c: otherwise>
17. I have not selected any favorite books.
18. </c: otherwise>
19. </c:choose>

Which of the following lines of code, if inserted independently at Line 5, will cause the text within the c: otherwise tag to display? (Choose all that apply)
A. books.add("");
B. books.add(null); -Answer in the book
C. books.clear();
D. books.add("Head First"); -Answer in the book
E. books = null;

Comments:
-Options A, B, and D all add something to the books List, making it NOT empty.
-Option C empties out the already empty List.
-Option E: Making the List reference a null value satisfies the empty operator.

#49 - Answer in the book is C, which I don't agree.
Given:
1. <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
2. <%@ taglib prefix="tables" uri="http://www.javaranch.com/tables" %>
3. <%@ taglib prefix="jsp" tagdir="/WEB-INF/tags" %>
4. <%@ taglib uri="UtilityFunctions" prefix="util" %>

What about the above taglib directives would cause the JSP to not function?
A. Line 4 is wrong because the prefix attribute must come before the
uri attribute.
B. Line 3 is wrong because there is no uri attribute.
C. Line 4 is wrong because the uri value must begin with http:// -Answer in the book
D. Line 3 is wrong because the prefix jsp is reserved for standard actions.

Comments:
-Option A: attributes can be in any order.
-Option B: when using Tag Files, tagdir is used instead of uri.
-Option C: a URI simply must match how the TLD is identified by the container.
-Option D: the jsp prefix is reserved for standard actions.


SCJP 5, SCWCD 5
Only The Strong Survive!
Luis Centeno
Ranch Hand

Joined: Jul 31, 2009
Posts: 46
Hi Marlo...

Please take a look at HFSJ errata. There, you will find answers to any doubt you might have about correctness on HFSJ book.

Regards

Luis


SCJP 6 | SCWCD 5
Marlo Magpantay
Greenhorn

Joined: Sep 15, 2010
Posts: 15
Cool! Thanks for the link!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question regarding answers in HFSJ 2nd ed mock exam