SUBJECT
CODE: 602 SUBJECT NAME: ADVANCED JAVA
Unit 3 :
JSP and SERVLET
1) JavaServer Pages often serve the same purpose as programs
implemented
using the Common Gateway Interface (CGI)
A) True
B) False
Answer:A
2) Which action tags are used in JSP for developing web
application with Java
Bean?
A) jsp:useBean
B) jsp:setProperty
C) jsp:getProperty
D) Both B & C
Answer:D
3) Which technology do we mix our business logic with the
presentation logic?
A) Servlet
B) JSP
C) Both A & B
D) None of the above
Answer:A
4) Which is the Microsoft solution for providing dynamic Web
content?
A) ASP
B) JSP
C) Both A & B
D) None of the above
Answer:A
5) A bean encapsulates many objects into one object, so we
can accessthis
object from multiple places.
A) True
B) False
Answer:A
6) Which tag is used to execute java source code in JSP?
A) Declaration Tag
B) Scriptlet tag
C) Expression tag
D) None of the above
Answer:B
7) Which JSP Action tags is used to include the content of
another resource,it
May be jsp, html or servlet?
A) jsp:include
B) jsp:forward
C) jsp:plugin
D) jsp:papam
Answer:A
8) In JSP how many ways are there to perform exception
handling?
A) 3
B) 2
C) 4
D) 5
Answer:B
9) In JSP page directive which attribute defines
theMIME(Multipurpose
Internet Mail Extension) type of the HTTP response?
A) import
B) Content Type
C) Extends
D) Info
Answer:B
10) A JSP page consists of which tags?
A) HTML tags
B) JSP tags
C) Both A & B
D) None of the above
Answer:C
11) Connection Pooling Class manages no of user requests for
connectionsto
improve the performance.
A) True
B) False
Answer:A
12) Which object of HttpSession can be used to view and
manipulate information
about a session?
A) session identifier
B) creation time
C) last accessed time
D) All mentioned above
Answer:D
13) Using mail API we cannot send mail from a servlet.
A) True
B) False
Answer:B
14) Which class provides stream to read binary data such as
image etc fromthe
request object?
A) ServltInputStream
B) ServletOutputStream
C) Both A & B
D) None of the above
Answer:A
15) The sendRedirect() method of HttpServletResponse
interface can be used to
redirect response to another resource, it may be servlet, jsp
or html file.
A) True
B) False
Answer:A
16) Which of these ways used to communicate from an applet to
servlet?
A) RMI Communication
B) HTTP Communication
C) Socket Communication
D) All mentioned above
Answer:D
17) Which methods are used to bind the objects on HttpSession
instance andget
the objects?
A) setAttribute
B) getAttribute
C) Both A & B
D) None of the above
Answer:C
18) Which type of ServletEngine is a server that includes
built-in support for
servlets?
A) Add-on ServletEngine
B) Embedded ServletEngine
C) Standalone ServletEngine
D) None of the above
Answer:C
19) What type of servlets use these methods doGet(), doPost(),doHead,
doDelete(),
doTrace()?
A) Genereic Servlets
B) HttpServlets
C) All of the above
D) None of the above
Answer:B
20) Which cookie it is valid for single session only and it
is removed each time
when the user closes the browser?
A) Persistent cookie
B) Non-persistent cookie
C) All the above
D) None of the above
Answer:B
21) Choose
the statement that best describes the relationship between JSP and
servlets:
A) Servlets
are built on JSP semantics and all servlets are compiled to JSP
pages for
runtime usage.
B) JSP and
servlets are unrelated technologies.
C) Servlets
and JSP are competing technologies for handling web requests.
Servlets
are being superseded by JSP, which is preferreD) The two
technologies
are not useful in combination.
D) JSPs are
built on servlet semantics and all JSPs are compiled to servlets for
runtime
usage.
Answer: D
22) What is
a benefit of using JavaBeans to separate business logic from
presentation
markup within the JSP environment?
A) It
allows the JSP to access middleware.
B) It
creates a cleaner role separation between the web-production team and
the
software development team, so that the web-production team can
focus on
presentation markup, while the software team can focus on building
reusable
software components for helping to generate dynamic displays.
C) It
provides a dynamic markup environment, such that JavaBeans are
integrated
seamlessly with the template presentation content, in order to
create the
dynamic display for the client.
D) It
provides the developer with full access to the Java 2 Platform Enterprise
Edition
(J2EE), which is unavailable from outside the JavaBean
environment.
Answer: B
23) Why use RequestDispatcher to forward a request to another
resource, instead
of using a sendRedirect?
A) Redirects are no longer supported in the current servlet
API.
B) Redirects are not a cross-platform portable mechanism.
C) The RequestDispatcher does not use the reflection API.
D) The RequestDispatcher does not require a round trip to the
client, and thus
is more efficient and allows the server to maintain request
state.
Ans: D
24) What alternatives exist to embedding Java code directly
within the HTML
markup of your JSP page?
A) Moving the code into your session manager.
B) Moving the code into scriptlets.
C) Moving the code into JavaBeans and servlets.
D) Moving the code into a transaction manager.
Answer: C
25) What type of scriptlet code is better-suited to being
factored forward into a
servlet?
A) Code that deals with logic that is common across requests.
B) Code that deals with logic that is vendor specifiC)
C) Code that deals with logic that relates to database
access.
D) Code that deals with logic that relates to client scope.
Answer: A
26) Choose
the statement that best describes how to connect JSP pages and
Enterprise
JavaBeans (EJBs):
A) Lookup
the EJBs from within a JSP, but use the EJBs from within a basic
JavaBean.
B) Lookup
and use the EJBs from a separate business delegate. The JavaBeans
that work
with JSP pages are clients to these business delegates and
know
nothing about EJB specifics.
C) Lookup
and use the EJBs from within a JSP page, but only as remote
references.
D) Lookup
the EJBs from within a servlet, delegating usage to specific JSP
pages.
Answer: B
27) Are custom tags available in JSP 1.0? If not, how else
might you implement
iteration from within a JSP?
A) Yes, but the only tags available relate to database
access.
B) No. To iterate over a collection of values, one must use
scriptlet code.
C) No, but there is a standard <iterate> tag that may
be useD)
D) Yes, but custom tags will not help developers create tags
for use in iterating
over a collection.
Answer: B
28) What is the initial contact point for handling a web
request in a Page-Centric
architecture?
A) A JSP page.
B) A JavaBean.
C) A servlet.
D) A session manager.
Answer: A
29) What is the difference between doing an include or a
forward with a RequestDispatcher?
A) The forward method transfers control to the designated resource,
while the
include method invokes the designated resource, substitutes
its
output dynamically in the display, and returns control to the
calling page.
B) The two methods provide the same functionality, but with
different levels
of persistence.
C) The forward method is deprecated as of JSP 1.1 and the
include method
should be used in order to substitute portions of a dynamic
display at
runtime.
D) The include method transfers control to a dynamic
resource, while the forward method allows for dynamic substitution of another
JPS pages output, returning control to the calling resource.
Answer: A
30) What line of code below might be combined in the same JSP
page with a
validation guard (for example, <% bean.validationGuard();
%> ), in order to
create an alternate flow of control for scenarios in which
exceptions arise. The
validationGaurd method might throw an exception, which should
cause
the flow of control to continue in another user-defined page
(assume JSP 1.0).
A) <jsp:error page=”errorPage.jsp” guard=”true” />
B) <%@ page language=”java” buffer=”8k” %>
C) <jsp:useBean id=”bean” class=”examples.Bean”
scope=”request” />
D) <%@ page language=”java” errorPage=”errorPage.jsp”
buffer=”8k” %>
Answer: D
31) JSP stands for __ ?
A) Java Server Pages
B) Java Service Page
Answer: A
32) What is a Hidden Comment in JSP?
A) <%– –%>
B) <%– %>
Answer: A
33) What is a Expression in JSP?
A) <%= %>
B) <% %>
Answer: A
34) pageContext is an implicit object in jsp.
A) TRUE
B) FALSE
Answer: A
35) config is an implicit object in jsp.
A) TRUE
B) FALSE
Answer: A
36) What is the result of adding following header?
response.addDateHeader(“Expires”,-1);
A) To ensure the page does not get cached at the client
browsers.
B) To ensure the page is accessible on any date and page
doesnt get expireD)
Answer: A
37) Given following form:
<form action=”register.do”>
<input type=”text” name=”Name”>
<input type=”submit” value=”Save”>
</form>
and a servlet code:
public class RegisterServlet extends HttpServlet{
pulic void doPost(HttpServletRequest req, HttpServletResponse
res) {
// registration logic goes here
return;}}
with the above code, assuming the servlet is configured
properly and registration logic works good, trying to register user fails.
Choose one reason.
A) The registration fails because, above servlet dont have
doGet() methoD)
B) The registration fails because, above servlet dont have
service() methoD)
Answer: A
38) Which of the following statements is true regarding the
scope of ‘request’ in
JSP?
A) Objects with request scope are accessible from pages
processing the same
request where they were createD)
B) All references to the object shall be released after the
request is processed;
in particular, if the request is forwarded to a resource in
the
same runtime, the object is still reachable.
C) References to objects with request scope are stored in the
request object.
D) All of the above.
Answer: A
39) URL encoding is the method of replacing all the spaces and
other extra
characters into their corresponding _______ Characters?
A) Hex
B) Binary
C) Octal
D) Decimal
Answer: A
40) Which of the scripting of JSP not putting content into
service method of the
converted servlet?
A) Declarations
B) Scriptlets
C) Expressions
D) None of the above
Answer: A
0 Comments