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?
Explanation: Directive is declared as <%@directive%>.
2. Which of the following action variable is used to include a file in JSP?
Explanation: jsp:include action variable is used to include a file in JSP.
3. Which attribute uniquely identification element?
Explanation: ID attribute is used to uniquely identify action element.
4. “out” is implicit object of which class?
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?
Explanation: pageContext object contains information about directives issued to JSP page.
6. What temporarily redirects response to the browser?
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?
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?
Explanation: <!–comment–> is an HTML comment. <%–comment–%> is JSP comment.
9. Java code is embedded under which tag in JSP?
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
Explanation: command directive is not a directive in JSP.
Sanfoundry Global Education & Learning Series – Java Programming Language.