This set of Advanced Java Multiple Choice Questions & Answers (MCQs) focuses on “JSP”.
1. Which page directive should be used in JSP to generate a PDF page?
a) contentType
b) generatePdf
c) typePDF
d) contentPDF
View Answer
Explanation: <%page contentType=”application/pdf”> tag is used in JSP to generate PDF.
2. Which tag should be used to pass information from JSP to included JSP?
a) Using <%jsp:page> tag
b) Using <%jsp:param> tag
c) Using <%jsp:import> tag
d) Using <%jsp:useBean> tag
View Answer
Explanation: <%jsp:param> tag is used to pass information from JSP to included JSP.
3. Application is instance of which class?
a) javax.servlet.Application
b) javax.servlet.HttpContext
c) javax.servlet.Context
d) javax.servlet.ServletContext
View Answer
Explanation: Application object is wrapper around the ServletContext object and it is an instance of a javax.servlet.ServletContext object.
4. _jspService() method of HttpJspPage class should not be overridden.
a) True
b) False
View Answer
Explanation: _jspService() method is created by JSP container. Hence, it should not be overridden.
5. Which option is true about session scope?
a) Objects are accessible only from the page in which they are created
b) Objects are accessible only from the pages which are in same session
c) Objects are accessible only from the pages which are processing the same request
d) Objects are accessible only from the pages which reside in same application
View Answer
Explanation: Object data is available till session is alive.
6. Default value of autoFlush attribute is?
a) true
b) false
View Answer
Explanation: Default value “true” depicts automatic buffer flushing.
7. Which one is the correct order of phases in JSP life cycle?
a) Initialization, Cleanup, Compilation, Execution
b) Initialization, Compilation, Cleanup, Execution
c) Compilation, Initialization, Execution, Cleanup
d) Cleanup, Compilation, Initialization, Execution
View Answer
Explanation: The correct order is Compilation, Initialization, Execution, Cleanup.
8. “request” is instance of which one of the following classes?
a) Request
b) HttpRequest
c) HttpServletRequest
d) ServletRequest
View Answer
Explanation: request is object of HttpServletRequest.
9. Which is not a directive?
a) include
b) page
c) export
d) useBean
View Answer
Explanation: Export is not a directive.
10. Which is mandatory in <jsp:useBean /> tag?
a) id, class
b) id, type
c) type, property
d) type,id
View Answer
Explanation: The useBean searches existing object and if not found creates an object using class.
No comments:
Post a Comment