You are on page 1of 13

Q 1 - What is the correct signature of jspInit() method of HttpJspPage class?

A - void jspInit(HTTPRequest request, HTTPResponse response)


B - void jspInit(HTTPRequest request, HTTPResponse response) throws
ServletException, IOException
C - void jspInit()
D - void jspInit() throws ServletException, IOException
Show Answer
Q 2 - Setting isThreadSafe false can lead to poor performance.
A - True
B - False
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 3 - Which of the following attributes are mandatory in <jsp:setProperty /> tag?
A - name, property
B - type, id
C - name, type
D - id, property
Answer : A
Explaination
The setProperty action sets the properties of a Bean. The Bean must have been
previously defined before this action.
Q 4 - Which of the following is true about session scope?
A - Object created with request scope are accessible only from the page in which
they are created.
B - Object created with request scope are accessible only from the pages which
are in same session.
C - Object created with request scope are accessible only from the pages which
are processing the same request.
D - Object created with request scope are accessible only from the pages which
reside in same application.
Answer : B
Explaination
Object created with request scope are accessible only from the pages which are in
same session. Object data is available till session is alive.
Q 5 - pageContext is instance of which class?
A - javax.servlet.ServletContext
B - javax.servlet.ServletConfig
C - javax.servlet.jsp.PageContext

D - javax.servlet.Application
Answer : C
Explaination
The pageContext object is an instance of a javax.servlet.jsp.PageContext object.
The pageContext object is used to represent the entire JSP page
Q 6 - What is default value of autoFlush Attribute?
A - true
B - false
Answer : A
Explaination
A value of true (default) indicates automatic buffer flushing and a value of false
throws an exception.
Q 7 - Which of the following is true about isThreadSafe Attribute?
A - The isThreadSafe option marks a page as being thread-safe.
B - If you set the isThreadSafe option to false, the JSP engine makes sure that only
one thread at a time is executing your JSP.
C - By default, all JSPs are considered thread-safe.
D - All of the above.
Answer : D
Explaination
The isThreadSafe option marks a page as being thread-safe. By default, all JSPs
are considered thread-safe. 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 8 - Which of the following is true about <jsp:forward> action?
A - The forward action terminates the action of the current page.
B - The forward action forwards the request to another resource such as a static
page, another JSP page, or a Java Servlet.
C - Both of the above.
D - None of the above.
Show Answer
Answer : C
Explaination
The forward action terminates the action of the current page and forwards the
request to another resource such as a static page, another JSP page, or a Java
Servlet.
Q 9 - What is Internationalization?
A - Internationalization means creating international content on a website.
B - Internationalization means enabling a web site to provide different versions of
content translated into the visitor's language or nationality.
C - Internationalization refers to creating local content on a website.

D - None of the above.


Answer : B
Explaination
Internationalization means enabling a web site to provide different versions of
content translated into the visitor's language or nationality.
Q 10 - What is the use of <c:if> tag?
A - It is used to check if jsp tag library is enabled or not.
B - It evaluates an expression and displays its body content only if the expression
evaluates to true.
C - Both of the above.
D - None of the above.
Answer : B
Explaination
The <c:if> tag evaluates an expression and displays its body content only if the
expression evaluates to true.
Q 1 - _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 2 - 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 3 - Which of the following are the valid scopes in JSP?
A - request, page, session, application
B - request, page, session, global
C - response, page, session, application
D - request, page, context, application
Answer : A
Explaination
The scope attribute identifies the lifecycle of the Action element. It has four possible
values: (a) page, (b) request, (c) session, and (d) application.

Q 4 - Which of the following attribute is used to mark a page as error processing


page?
A - isErrorPage
B - errorPage
C - exception
D - exceptionPage
Answer : A
Explaination
<%@ page isErrorPage="true" %>
Within jsp, indicate that it is an error-processing page, using the above directive.
Q 5 - pageContext is instance of which class?
A - javax.servlet.ServletContext
B - javax.servlet.ServletConfig
C - javax.servlet.jsp.PageContext
D - javax.servlet.Application
Answer : C
Explaination
The pageContext object is an instance of a javax.servlet.jsp.PageContext object.
The pageContext object is used to represent the entire JSP page.
Q 6 - What happens when buffer is set to a value "none"?
A - Servlet output is immediately directed to the response output object.
B - Compilation error.
Answer : A
Explaination
When buffer is set to "none", servlet output is immediately directed to the response
output object.
Q 7 - What will happen if isScriptingEnabled attribute is set as false?
A - A translation-time error will be raised if the JSP uses any scriptlets, expressions
(non-EL), or declarations.
B - JSP container will ignore the any scriptlets, expressions (non-EL), or
declarations similar to comments.
C - Both of the above.
D - None of the above.
Answer : A
Explaination
A translation-time error will be raised if the JSP uses any scriptlets, expressions
(non-EL), or declarations.
Q 8 - Which of the following is true about Initialization phase in JSP life cycle?

A - When a container loads a JSP it invokes the jspInit() method before servicing
any requests.
B - Container invokes _jspService() method during Initialization phase.
C - Both of the above.
D - None of the above.
Answer : A
Explaination
When a container loads a JSP it invokes the jspInit() method before servicing any
requests.
Q 9 - Is JSP technology extensible?
A - true
B - false
Show Answer
Answer : A
Explaination
Yes. JSP technology is extensible through the development of custom actions, or
tags, which are encapsulated in tag libraries.
Q 10 - What's the difference between JavaBeans and taglib directives?
A - Taglibs are for generating presentation elements while JavaBeans are good for
storing information and state.
B - Custom tags are used to implement actions and JavaBeans are used to present
information.
C - Both of the above.
D - None of the above.
Answer : A
Explaination
JavaBeans and taglib fundamentals were introduced for reusability. But following
are the major differences between them:
Taglibs are for generating presentation elements while JavaBeans are good
for storing information and state.
Use custom tags to implement actions and JavaBeans to present information.
Q 1 - response is instance of which class?
A - Response
B - HttpResponse
C - HttpServletResponse
D - ServletResponse
Answer : C
Explaination
request is object of HttpServletResponse.

Q 2 - 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 3 - Which of the following is true about request scope?
A - Object created with request scope are accessible only from the page in which
they are created.
B - Object created with request scope are accessible only from the pages which
are in same session.
C - Object created with request scope are accessible only from the pages which
are processing the same request.
D - Object created with request scope are accessible only from the pages which
reside in same application.
Answer : C
Explaination
Object created with request scope are accessible only from the pages which are
processing the same request. Object data is available to another page in case of
forward.
Q 4 - Which of the following attributes are used in <jsp:include /> tag?
A - id, type
B - page, flush
C - type, class
D - type,page
Answer : B
Explaination
<jsp:include /> lets you insert files into the page being generated. The syntax looks
like this:
<jsp:include page="relative URL" flush="true" />
Where page is the the relative URL of the page to be included. Flush is the boolean
attribute the determines whether the included resource has its buffer flushed before
it is included.
Q 5 - Which of the following method can be used to read parameters names?
A - request.getParameter()
B - response.getParameter()
C - request.getParameterNames()
D - response.getParameterNames()

Answer : C
Explaination
You call request.getParameterNames() method to get the names of all the
parameters passed.
Q 6 - Which of the following is true about import Attribute?
A - The import attribute serves the same function as, and behaves like, the Java
import statement.
B - The value for the import option is the name of the package you want to import.
C - Both of the above.
D - None of the above.
Answer : C
Explaination
The import attribute serves the same function as, and behaves like, the Java import
statement. The value for the import option is the name of the package you want to
import.
Q 7 - What is the default value of isScriptingEnabled attribute?
A - true
B - false
Answer : A
Explaination
The default value (true) of isScriptingEnabled attribute enables scriptlets,
expressions, and declarations.
Q 8 - Is it possible to include files using absolute path in a JSP page using include
directive?
A - true
B - false
Answer : A
Explaination
No! include directive takes relative URL with respect to current domain of web
application.
Q 9 - Which of the following is true about locale?
A - This is a particular cultural or geographical region.
B - Locale is usually referred to as a language symbol followed by a country
symbol which are separated by an underscore.
C - Both of the above.
D - None of the above
Answer : C
Explaination

Locale is a particular cultural or geographical region. It is usually referred to as a


language symbol followed by a country symbol which are separated by an
underscore. For example "en_US" represents english locale for US.
Q 10 - What is the use of <c:remove > tag?
A - It removes a item from a list
B - it removes the data row from the database.
C - It removes a variable from either a specified scope or the first scope where the
variable is found
D - None of the above.
Answer : C
Explaination
The <c:remove > tag removes a variable from either a specified scope or the first
scope where the variable is found (if no scope is specified).

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


A - True
B - False
Answer : A
Explaination
Yes, jspDestroy() method can be overridden.
Q 2 - 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 3 - 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.
4 - Which of the following is true about language attribute?
A - The language attribute indicates the programming language used in scripting
the servlet.
B - The language attribute indicates the programming language used in scripting
the html page.
C - The language attribute indicates the programming language used in scripting
the JSP page.
D - None of the above.
Answer : C
Explaination
The language attribute indicates the programming language used in scripting the
JSP page.
Q 5 - Which of the following method can be used to read a form parameter in JSP?
A - request.getParameter()
B - response.getParameter()
C - request.getValue()
D - response.getValue()
Answer : A
Explaination
You call request.getParameter() method to get the value of a form parameter.
Q 6 - What are cookies?

A - Cookies are text files stored on the client computer and they are kept for
various information tracking purpose.
B - Cookies are binary files stored on the server computer and they are kept for
various information tracking purpose.
C - Cookies are binary files stored on the client computer and they are kept for data
storage purpose.
D - None of the above.
Answer : A
Explaination
Cookies are text files stored on the client computer and they are kept for various
information tracking purpose.
Q 7 - What will happen if isScriptingEnabled attribute is set as false?
A - A translation-time error will be raised if the JSP uses any scriptlets, expressions
(non-EL), or declarations.
B - JSP container will ignore the any scriptlets, expressions (non-EL), or
declarations similar to comments.
C - Both of the above.
D - None of the above.
Answer : A
Explaination
A translation-time error will be raised if the JSP uses any scriptlets, expressions
(non-EL), or declarations.
Q 8 - Which of the following is true about Cleanup phase in JSP life cycle?
A - The destruction phase of the JSP life cycle represents when a JSP is being
removed from use by a container.
B - The jspDestroy() method is the JSP equivalent of the destroy method for
servlets.
C - Both of the above.
D - None of the above.
Answer : C
Explaination
The destruction phase of the JSP life cycle represents when a JSP is being
removed from use by a container.The jspDestroy() method is the JSP equivalent of
the destroy method for servlets.
Q 9 - Is JSP technology extensible?
A - true
B - false
Answer : A
Explaination
Yes. JSP technology is extensible through the development of custom actions, or
tags, which are encapsulated in tag libraries.
Q 10 - What is the use of <c:catch> tag?

A - to catch any Throwable that occurs in its body and optionally exposes it.
B - to catch the runtime error and redirect to error page.
C - Both of the above.
D - None of the above.
Show Answer
Answer : A
Explaination
The <c:catch> tag catches any Throwable that occurs in its body and optionally
exposes it. Simply it is used for error handling and to deal more gracefully with the
problem.
Q 1 - Which of the following is not a implicit object?
A - request
B - response
C - cookie
D - session
Show Answer
Answer : C
Explaination
There is no cookie object in jsp.
Q 2 - if isThreadSafe attribute of page directive is set as true, then generated
servlet implements SingleThreadModel interface.
A - True
B - False
Show Answer
Answer : B
Explaination
If isThreadSafe attribute of page directive is set as false, then generated servlet
implements SingleThreadModel interface.
Q 3 - 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.
QQ 5 - What is true about filters?
A - JSP Filters are used to intercept requests from a client before they access a
resource at back end.
B - JSP Filters are used to manipulate responses from server before they are sent
back to the client.
C - Both of the above.

D - None of the above.


Answer : C
Explaination
JSP Filters are Java classes that can be used in JSP Programming for both of the
above purposes.
Q4 - Which of the following is true about language attribute?
A - The language attribute indicates the programming language used in scripting
the servlet.
B - The language attribute indicates the programming language used in scripting
the html page.
C - The language attribute indicates the programming language used in scripting
the JSP page.
D - None of the above.
Answer : C
Explaination
The language attribute indicates the programming language used in scripting the
JSP page.
Q 6 - What happens when autoFlush is set to a value "false"?
A - JSP container throws exceptionto indicate buffer overflow when buffer is filled.
B - JSP container flushed the buffered output when buffer is filled.
C - Both of the above.
D - None of the above.
Answer : A
Explaination
A value of true (default) indicates automatic buffer flushing and a value of false
throws an exception.
Q 7 - Which of the following is true about info Attribute?
A - The info attribute lets you provide a description of the JSP.
B - The info attribute is used by JSP container for optimization of generated servlet
code.
C - Both of the above.
D - None of the above.
Answer : A
Explaination
The info attribute lets you provide a description of the JSP.
Q 8 - Which of the following step is taken by JSP container during Compilation
phase?
A - Parsing the JSP.
B - Turning the JSP into a servlet.
C - Compiling the servlet.
D - All of the above.
Answer : C

Explaination
The compilation process involves three steps: a) Parsing the JSP, b) Turning the
JSP into a servlet, c) Compiling the servlet.
Q 9 - Can you make use of a ServletOutputStream object from within a JSP page?
A - true
B - false
Answer : B
Explaination
No. You are supposed to make use of only a JSPWriter object (given to you in the
form of the implicit object out) for replying to clients.
Q 10 - What's the difference between JavaBeans and taglib directives?
A - Taglibs are for generating presentation elements while JavaBeans are good for
storing information and state.
B - Custom tags are used to implement actions and JavaBeans are used to present
information.
C - Both of the above.
D - None of the above.
Answer : A
Explaination
JavaBeans and taglib fundamentals were introduced for reusability. But following
are the major differences between them:
Taglibs are for generating presentation elements while JavaBeans are good
for storing information and state.
Use custom tags to implement actions and JavaBeans to present information.

You might also like