Time remaining
:
:
Test Status
JSPRANDOMTEST
Ques 1 :
What is the key difference between using a <jsp:forward> and HttpServletResponse.sendRedirect()?
(A) The two methods perform identically.
(B) forward executes on the client while sendRedirect() executes on the server.
(C) forward executes on the server while sendRedirect() executes on the client.
Ques 2 :
What gets printed when the following JSTL code fragment is executed? Select the one correct answer.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="item" value="2"/>
<c:forEach var="item" begin="0" end="0" step="2">
<c:out value="${item}" default="abc"/>
</c:forEach>
The JSTL code does not compile as an attribute for forEach tag is not correct.
(A) 0
(B) ABC
(C) 2
(D) Nothing gets printed as c.out statement does not get executed.
Ques 3 :
Which of the following correctly represents the following JSP statement. Select the one correct answer.
(A)
x
(B)
x
(C)
x
(D)
x
Ques 4 :
Why DB connections are not written directly in JSPs ?
(A) Not a standard J2EE architecture
(B) Load Balancing is not possible
(C) All the above
(D) Both (b) and (c)
Ques 5 :
What gets printed when the following JSTL code fragment is executed? Select the one correct answer.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="item" value="2"/>
<c:if test="${var==1}" var="result" scope="session">
<c:out value="${result}"/>
</c:if>
(A) true
(B) The JSTL code does not compile as attribute for if tag are not correct.
(C) false
(D) Nothing gets printed.
Ques 6 :
How many numbers are printed, when the following JSTL code fragment is executed? Select the one correct answer.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
${item}
(A) 1
(B) 5
(C) 6
(D) 11
Ques 7 :
What gets printed when the following is compiled. Select the one correct answer.
<% int y = 0; %>
<% int z = 0; %>
<% for(int x=0;x<3;x++) { %>
<% z++;++y;%>
<% }%>
<% if(z<y) {%>
<%= z%>
<% } else {%>
<%= z - 1%>
<% }%>
(A) 1
(B) 2
(C) 3
(D) The program generates compilation error.
Ques 8 :
Which of the following JSP variables are not available within a JSP expression. Select the one correct answer.
(A) out
(B) httpsession
(C) session
(D) request
Ques 9 :
What is the effect of executing the following JSP statement, assuming a class with name Employee exists in classes package.
<%@ page import = "classes.Employee" %> <jsp:useBean id="employee" class="classes.Employee" scope="session"/> <jsp:setProperty name="employee" property="*"/>
(A) The code does not compile as property attribute cannot take * as a value.
(B) The code sets value of all properties of employee bean to "*".
(C) The code sets the values of all properties of employee bean to matrching parameters in request object.
(D) The code does not compile as there is no property attribute of setProperty tag.
Ques 10 :
Which numbers gets printed when the following JSTL code fragment is executed? Select the correct answers.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="j" value="4,3,2,1"/>
<c:forEach items="${j}" var="item" begin="1" end="2">
<c:out value="${item}" default="abc"/>
</c:forEach>
(A) 1
(B) 4
(C) 2
(D) abc
Ques 11 :
What gets printed when the following JSP code is invoked in a browser. Select the one correct answer.
<%= if(Math.random() < 0.5) %>
hello
<%= } else { %>
hi
<%= } %>
(A) The browser will print either hello or hi based upon the return value of random.
(B) The string hello will always get printed.
(C) The string hi will always get printed.
(D) The JSP file will not compile.
Ques 12 :
A JSP page called test.jsp is passed a parameter name in the URL using http://localhost/test.jsp?name="John". The test.jsp contains the following code.
1 <%! String myName=request.getParameter();%>
2 <% String test= "welcome" + myName; %>
3 <%= test%>
(A) The program prints "Welcome John"
(B) The program gives a syntax error because of the statement 1
(C) The program gives a syntax error because of the statement 2
(D) The program gives a syntax error because of the statement 3
Ques 13 :
Why beans are used in J2EE architecture in stead of writing all the code in JSPs?
(A) Allows separation of roles between web developers and application developers
(B) Allows integration with Content Management tools
Ques 14 :
Which of the following are correct. Select the one correct answer.
(A) JSP scriptlets and declarations result in code that is inserted inside the _jspService method.
(B) The JSP statement <%! int x; %> is equivalent to the statement
int x;
.
(C) The following are some of the predefined variables that maybe used in JSP expression - httpSession, context.
(D) To use the character %> inside a scriptlet, you may use %\> instead.
Ques 15 :
How many numbers gets printed when the following JSTL code fragment is executed? Select the one correct answer.
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="item" value="2"/>
<c:choose>
<c:when test="${item>0}">
<c:out value="1"/>
</c:when>
<c:when test="${item==2}">
<c:out value="2"/>
</c:when>
<c:when test="${item<2}">
<c:out value="3"/>
</c:when>
<c:otherwise>
<c:out value="4"/>
</c:otherwise>
</c:choose>
(A) One number gets printed.
(B) Two numbers gets printed.
(C) Three numbers gets printed.
(D) Four numbers gets printed.
Ques 16 :
Which of these represent the correct path for the core JSTL library in JSTL version 1.1? Select the one correct answer.
(A) http://java.sun.com/jsp/jstl/core
(B) http://java.sun.com/jsp/core
(C) http://java.sun.com/core
(D) http://java.sun.com/jsp/jstl1.1/core
Ques 17 :
In JSP, how can you know what HTTP method (GET or POST) is used by client request ?
(A) by using request.setMethod()
(B) impossible to know
(C) by using request.getMethod()
Ques 18 :
Which of the following is legal JSP syntax to print the value of i. Select the one correct answer
(A) <%= i; %>
(B) <%int i = 1;%>
(C) <%int i = 1; i; %>
(D) <%int i = 1%>
Ques 19 :
Which of the following correctly represents the following JSP statement. Select the one correct answer.
(A)
x=1;
(B)
x=1;
(C)
x=1;
(D)
x=1;
Ques 20 :
Given that www.example.com/SCWCDtestApp is a validly deployed Java EE web application and that all of the JSP files specified in the requests below exist in the locations specified.Which two requests, issued from a browser, will return an HTTP 404 error?
(A) http://www.example.com/SCWCDtestApp/test.jsp
(B) http://www.example.com/SCWCDtestApp/Customer/test.jsp
(C) http://www.example.com/SCWCDtestApp/WEB-INF/test.jsp
(D) http://www.example.com/SCWCDtestApp/Customer/Update/test.jsp
Submit Answer
Don't Refresh the Page !! ...