JSP Mock Test



This section presents you various set of Mock Tests related to JSP Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Questions and Answers

JSP Mock Test I

Answer : C

Explaination

Correct Signature is void jspInit()

Answer : B

Explaination

Correct Signature is

void _jspService(HTTPRequest request, HTTPResponse response) throws ServletException, IOException

Q 4 - _jspService() method of HttpJspPage class should not be overridden.

A - True

B - False

Answer : A

Explaination

JSP container creates _jspService() methods so it should not be overridden.

Q 5 - _jspService() method of HttpJspPage class should not be overridden.

A - True

B - False

Answer : A

Explaination

JSP container creates _jspService() methods so it should not be overridden.

Q 6 - jspInit() method of HttpJspPage class can be overridden.

A - True

B - False

Answer : A

Explaination

Yes, jspInit() method can be overridden.

Q 7 - jspDestroy() method of HttpJspPage class can be overridden.

A - True

B - False

Answer : A

Explaination

Yes, jspDestroy() method can be overridden.

Q 8 - Which of the following is not a implicit object?

A - request

B - response

C - cookie

D - session

Answer : C

Explaination

There is no cookie object in jsp.

Q 9 - request is instance of which class?

A - Request

B - HttpRequest

C - HttpServletRequest

D - ServletRequest

Answer : C

Explaination

request is object of HttpServletRequest.

Q 10 - response is instance of which class?

A - Response

B - HttpResponse

C - HttpServletResponse

D - ServletResponse

Answer : C

Explaination

request is object of HttpServletResponse.

Q 11 - if isThreadSafe attribute of page directive is set as true, then generated servlet implements SingleThreadModel interface.

A - True

B - False

Answer : B

Explaination

If isThreadSafe attribute of page directive is set as false, then generated servlet implements SingleThreadModel interface.

Q 12 - This object can be used to access other implicit objects in JSP.

A - request

B - page

C - context

D - pageContext

Answer : D

Explaination

pageContext can be used to retrieve other implicit objects using its methods like getPage(), getRequest() etc.

Q 13 - What is default value of isThreadSafe?

A - True

B - False

Answer : A

Explaination

The isThreadSafe option marks a page as being thread-safe. By default, it is true and all JSPs are considered thread-safe.

Q 14 - Setting isThreadSafe false can lead to poor performance.

A - True

B - False

Answer : A

Explaination

If you set the isThreadSafe option to false, the JSP engine makes sure that only one thread at a time is executing your JSP.

Q 15 - session is instance of which class?

A - Session

B - HttpSession

C - HttpServletSession

D - ServletSession

Answer : B

Explaination

request is object of HttpSession.

Q 16 - If a jsp is to generate a pdf page, what attribute of page directive it should use?

A - contentType

B - generatePdf

C - typePDF

B - contentPDF

Answer : A

Explaination

<%page contentType="application/pdf">

Above tag is used to generate PDF using JSP.

Q 17 - If a jsp is to generate a xml page, what attribute of page directive it should use?

A - contentXML

B - generateXML

C - typeXML

D - contentType

Answer : D

Explaination

<%page contentType="text/xml">

Q 18 - Which of the following is not a directive?

A - include

B - page

C - export

D - useBean

Answer : C

Explaination

export is not a page directive.

Q 19 - Which of the following is not a valid attribute of a page directives?

A - language

B - extend

C - export

D - import

Answer : C

Explaination

export is not a valid attribute of a page directive.

Q 20 - Which of the following is a server side technology?

A - html

B - jsp

C - javaScript

D - css

Answer : B

Explaination

jsp is a server side technology.

Q 21 - All jsp pages are required to be mapped and configured in web.xml.

A - True

B - False

Answer : B

Explaination

No, Jsp pages are not required to be mapped/configured in web.xml

Q 22 - All servlet classes are required to be mapped and configured in web.xml.

A - True

B - False

Answer : A

Explaination

Yes, all servlets are required to be mapped/configured in web.xml

Q 23 - Which of the following do not supports JSP directly?

A - Weblogic Server

B - WebSphere Server

C - Tomcat Server

D - Apache HTTP Server

Answer : D

Explaination

Apache HTTP Server do not supports JSP directly.

Answer : D

Explaination

JSP stands for Java Server Pages.

Q 25 - Which is the methods of generated Servlet?

A - jspInit()

B - _jspService()

C - jspDestroy()

D - All of the above

Answer : D

Explaination

All of the above methods get generated in generated servlet.

Answer Sheet

Question Number Answer Key
1 C
2 C
3 B
4 A
5 A
6 A
7 A
8 C
9 C
10 C
11 B
12 D
13 A
14 A
15 B
16 A
17 D
18 C
19 C
20 B
21 B
22 A
23 D
24 D
25 D
jsp_questions_answers.htm
Advertisements