|
SCWCD : JSTL Mock Exam Practice Questions
What get printed when the following JSTL code fragment is executed?
<%@ 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="" default="abc"/>
</c:forEach>
options
A)0
B)2
C)abc
D)4
Correct answer is : A
Explanations : forEach tag gets executed once, and prints zero.
Questions no -2
What get printed when the following JSTL code fragment is executed?
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:forEach var="item" begin="0" end="12" step="3">
</c:forEach>
options
A)0,3,6,9,12
B)3,6,9,12
C)0,6,9,12
D)0,3,6,9
Correct answer is : A
Explanations :
start from 0 to end 12 and step is 3 so 0,3,6,9,12 printed.
| |