Advanced Java Questions & Answers – JSP

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

Answer: a
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

Answer: a
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

Answer: d
Explanation: Application object is wrapper around the ServletContext object and it is an instance of a javax.servlet.ServletContext object.
advertisement
advertisement

4. _jspService() method of HttpJspPage class should not be overridden.
a) True
b) False
View Answer

Answer: a
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

Answer: b
Explanation: Object data is available till session is alive.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. Default value of autoFlush attribute is?
a) true
b) false
View Answer

Answer: a
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

Answer: c
Explanation: The correct order is Compilation, Initialization, Execution, Cleanup.
advertisement

8. “request” is instance of which one of the following classes?
a) Request
b) HttpRequest
c) HttpServletRequest
d) ServletRequest
View Answer

Answer: c
Explanation: request is object of HttpServletRequest.

9. Which is not a directive?
a) include
b) page
c) export
d) useBean
View Answer

Answer: c
Explanation: Export is not a directive.
advertisement

10. Which is mandatory in <jsp:useBean /> tag?
a) id, class
b) id, type
c) type, property
d) type,id
View Answer

Answer: a
Explanation: The useBean searches existing object and if not found creates an object using class.

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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.