This set of Advanced Java Multiple Choice Questions & Answers (MCQs) focuses on “JSP Elements”.
1. Which one of the following is correct for directive in JSP?
a) <%@directive%>
b) <%!directive%>
c) <%directive%>
d) <%=directive%>
View Answer
Explanation: Directive is declared as <%@directive%>.
2. Which of the following action variable is used to include a file in JSP?
a) jsp:setProperty
b) jsp:getProperty
c) jsp:include
d) jsp:plugin
View Answer
Explanation: jsp:include action variable is used to include a file in JSP.
3. Which attribute uniquely identification element?
a) ID
b) Class
c) Name
d) Scope
View Answer
Explanation: ID attribute is used to uniquely identify action element.
4. “out” is implicit object of which class?
a) javax.servlet.jsp.PrintWriter
b) javax.servlet.jsp.SessionWriter
c) javax.servlet.jsp.SessionPrinter
d) javax.servlet.jsp.JspWriter
View Answer
Explanation: JspWriter object is referenced by the implicit variable out which is initialized automatically using methods in the PageContext object.
5. Which object stores references to the request and response objects?
a) sessionContext
b) pageContext
c) HttpSession
d) sessionAttribute
View Answer
Explanation: pageContext object contains information about directives issued to JSP page.
6. What temporarily redirects response to the browser?
a) <jsp:forward>
b) <%@directive%>
c) response.sendRedirect(URL)
d) response.setRedirect(URL)
View Answer
Explanation: response.sendRedirect(URL) directs response to the browser and creates a new request.
7. Which tag is used to set a value of a JavaBean?
a) <c:set>
b) <c:param>
c) <c:choose>
d) <c:forward>
View Answer
Explanation: <c:set> is used to set a value of a java.util.Map object.
8. Can <!–comment–> and <%–comment–%> be used alternatively in JSP?
a) True
b) False
View Answer
Explanation: <!–comment–> is an HTML comment. <%–comment–%> is JSP comment.
9. Java code is embedded under which tag in JSP?
a) Declaration
b) Scriptlet
c) Expression
d) Comment
View Answer
Explanation: Scriptlet is used to embed java code in JSP.
10. Which of the following is not a directive in JSP?
a) page directive
b) include directive
c) taglib directive
d) command directive
View Answer
Explanation: command directive is not a directive in JSP.
Sanfoundry Global Education & Learning Series – Java Programming Language.
To practice all areas of Java language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Practice BCA MCQs
- Practice Information Technology MCQs
- Practice Programming MCQs
- Apply for Java Internship
- Check Programming Books