Thursday, March 3, 2016

MCQ 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.

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.

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.

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.

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.


No comments:

Post a Comment

CORBA Java Tutorial using Netbeans and Java 8.

CORBA-Example A simple CORBA implementation using Java Echo.idl module EchoApp{ interface Echo{ string echoString(); }; }; ...