JSP Mock Test


Advertisements


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 IV

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.

Answer : C

Explaination

useBean action first searches for an existing object utilizing the id and scope variables. If an object is not found, it then tries to create the specified object. useBean is used to load java beans in jsp page.

Answer : C

Explaination

The setProperty action sets the properties of a Bean. The Bean must have been previously defined before this action.

Answer : C

Explaination

The getProperty action is used to retrieve the value of a given property and converts it to a string, and finally inserts it into the output.

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.

Answer : C

Explaination

sendRedirect sends HTTP temporary redirect response to the browser, and browser creates a new request to go the redirected page.

Answer : A

Explaination

JSTL, JavaServer Pages Standard Tag Library is a collection of useful JSP tags which encapsulates core functionality common to many JSP applications.

Answer : B

Explaination

Internationalization means enabling a web site to provide different versions of content translated into the visitor's language or nationality.

Answer : C

Explaination

Localization means adding resources to a web site to adapt it to a particular geographical or cultural region for example Hindi translation to a web site.

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 12 - 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 13 - Can a JSP page process HTML FORM data?

A - true

B - false

Answer : A

Explaination

Yes. However, unlike Servlet, you are not required to implement HTTP-protocol specific methods like doGet() or doPost() within your JSP page. You can obtain the data for the FORM input elements via the request implicit object within a scriptlet or expression.

Q 14 - 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.

Answer : A

Explaination

Using <%jsp:param> tag you can pass information from JSP to included JSP.

Answer : B

Explaination

The <c:set > tag is JSTL-friendly version of the setProperty action. The tag is helpful because it evaluates an expression and uses the results to set a value of a JavaBean or a java.util.Map object.

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

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.

Answer : B

Explaination

The <c:if> tag evaluates an expression and displays its body content only if the expression evaluates to true.

Answer : D

Explaination

The <c:choose> works like a Java switch statement in that it lets you choose between a number of alternatives. Where the switch statement has case statements, the <c:choose> tag has <c:when> tags. A a switch statement has default clause to specify a default action and similar way <c:choose> has <otherwise> as default clause.

Answer : C

Explaination

The <c:forEach > tag exists as a good alternative to embedding a Java for, while, or do-while loop via a scriptlet.

Answer : C

Explaination

The <c:param> tag allows proper URL request parameter to be specified with URL and it does any necessary URL encoding required.

Answer : D

Explaination

The <c:redirect > tag redirects the browser to an alternate URL by providing automatically URL rewriting, it supports context-relative URLs, and it supports the <c:param> tag.

Answer : C

Explaination

The <c:url> tag formats a URL into a string and stores it into a variable. This tag automatically performs URL rewriting when necessary.

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.

Answer Sheet

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

jsp_questions_answers.htm

Advertisements