http://www.enthuware.com/forum/viewtopic.php?f=31&t=13
Following are some of the questions from Enthuware.
I have posted all the questions in a single post as I thought that would be a better than posting them in different posts.
Its my request to the fellow ranchers to help me in the following questions.
---------------------------------------------------------------------------------------------------------------------------------------------------
Q. No. 2
Which of the following are valid
JSP code fragments?
Each option shows code for an independent JSP file.
(a) <%@ page import="java.util.*" autoFlush="true"%>
<%@ page import="java.io.*" autoFlush="false"%>
(b) <%Date d = new Date();
out.println(d);
%>
(c) <%=
String val = request.getParameter("hello");
out.println(val);
%>
(d) <%!
Hashtable ht = new Hashtable();
{
ht.put("max", "10");
}
%>
(e) <%!
Hashtable ht = new Hashtable();
ht.put("max", "10");
%>
ANSWER:B,D
I think answer should be A,B,D as the autoflush can have true as value.
--------------------------------------------------------------------------------
Q. No. 5
Identify the authentication techniques that are based on builtin mechanisms of HTTP.
(a) HTTP does not have any built in mechanism for authentication.
(b) BASIC
(c) CLIENT-CERT
(d) DIGEST
(e) FORM
B,d-correct answer
I unable to get the answer.please Help.
---------------------------------------------------------------------------------------
Q3.
Which of the following statements is correct regarding a RequestDispatcher object?
(a) A call to forward() clears the output buffer before the target resource is invoked.
(b) A call to include() clears the output buffer before the target resource is invoked.
(c) The execution control returns to the resource that has called the forward() method after the callee resource finishes processing.
(d) It is not advisable for the forwarding resource to produce any output.
(e) Both, forward() and include(), allow the caller resource to generate any amount of output.
Correct answer=a,c,d
I think answer should be a,d
If a.jsp has called forward to b.jsp then the calle i.e. b.jsp would have the control instead of a.jsp.So, the option c is incorrect
-------------------------------------------------------------------------------------------------------------------------------------------------
Q. No. 4
Consider the code for a jsp page :
Assuming that the
servlet context of the web application DOES NOT have any attribute by the name of "key",
what will the above jsp page print when requested?
(a) It will not compile because the getAttribute() returns an Object which must be cast to String before assigning to thevalue.
(b) It will print "null".
(c) It will throw a NullPointerException.
(d) It will print "" (empty string).
(e) None of these.
Correct answer: e
The correct answer is e as there will be a compilation error application cannot be resolved.
Am i correct ?
------------------------------------------------------------------------------------------------------------------------------------------
Q. No. 18
Which of the following statements are correct regarding the forEach tag of JSTL?
(a) It can iterate over collections as well as maps.
(b) It can only iterate over arrays and collections.
(c) The EL code within the body of the tag may refer to the iteration variable but scripting code cannot.
(d) It can iterate over a Map but only the 'keys' can be used in the EL code within the body of the tag.
(e) The status object cannot be used while looping over integers using begin and end attributes.
Correct-a,c
I think a,b,d are correct.
EL can be used to iterate over arrays
and the following code can be done:
So c is incorrect and must not be in the answer.
b,d should be in the answers.
--------------------------------------------------------------------------------------------
Q. No. 20
Given the following JSP code:
Which of the following correctly creates an HTML select box on the page?
(a) <select name="Cities">
<c:forEach var="city" items="${cities}" >
<option>${city}</option>
</c:forEach>
</select>
(b) <select name="Cities">
<c:forEach items="${cities}" >
<option>${cities[i]}</option>
</c:forEach>
</select>
(c) <select name="Cities">
<c:forEach var="city" items="${cities}" >
<option>${cities[city]}</option>
</c:forEach>
</select>
(d) None of these will work.
Correct answer is d
The code in option 1 is correct as per my understanding .
If I am incorrect ,please provide a reason.
------------------------------------------------------------------------------------------------------------------
Q. No. 27
Which of the following statements are correct?
(a) The implicit variable 'session' can be used to store values needed by other servlets or JSPs of the same web application.
(b) The implicit variable 'request' can be used to store values needed by other servlets or jsps across multiple requests.
(c) You can use the implicit variable 'response' to set the content type of the output.
(d) The implicit variable 'out' is same as returned by response.getWriter()
(e) All JSPs have access to 'request', 'response' and 'session' variables.
Correct answer-a and c
B can be correcr answer as well.It can also used for storing values needed by other servlets or jsps across multiple requests.
I am unable to understand why is b not in the correct answer list.