1
1
http://www.Word-to-PDF-Converter.net
Advanced Java Test
MARKS:45
a. x = 3, 5 b. x = 3, 7 c. x = 5, 3 d. x = 5, 7 e. Compilation Error
a) Services
b) APIs
c) Protocols
d) All of these
a) lifecycle management
b) deployment
c) security
d) threading
e) All of these
d) None of these
6.In J2EE packaging and deployment process, which of the role below creates and
modifies the deployment descriptor?
( Word to PDF Converter - Unregistered )
http://www.Word-to-PDF-Converter.net
a) Application component provider
b) Application assembler
c) Application Deployer
d) System Administrator
7. What object will the component create to look up the environment naming
context in InitialContext under the name java:comp/env?
a) java.naming.InitialContext
b) javax.naming.Context
c) javax.naming.InitialContext
d) javax.naming.NaminingContext
Server A does not have graphical display options so that the installation has to
happen as command-line installation.
Which of the following is used by installer to run from the command line, to specify
the configuration set, during the installation?
a. installgroup and install path options
b) WebApp.xml
c) server.xml
d) deployment.xml
e) Web.xml
a) class instantiation,
class loading,
service method,
( Word to PDF Converter - Unregistered )
http://www.Word-to-PDF-Converter.net
init method,
delete method
b) class loading,
class instantiation,
service method,
init method,
delete method
c) class loading,
class instantiation,
service method,
init method,
destroy method
d) class loading,
class instantiation,
init method,
service method,
delete method
e) class loading,
class instantiation,
init method
service method,
destroy method
10. Which of the following JSP tags can be used to print the value of an expression
to the output stream? (Choose 2)
a) <%@ %>
b) <%! %>
c) <% %>
d) <%= %>
e) <%-- --%>
al.add(“Jack Russell”);
( Word to PDF Converter - Unregistered )
http://www.Word-to-PDF-Converter.net
al.add(“Labrador”);
al.add(“Great Dane”);%>
<@include file=”two.jsp”%>
<%=al.get(i) %>
Which two of the following statements are true about the above two JSP page
a. Translation will fail because the import attribute of the page directive is
b. The order of the import and contentType attributes in both JSP page
sources is immaterial.
directives
12. Every page of your web site must include a common set of navigation menus at
the top of the page. This menu is static HTML and changes frequently, so you have
decided to use JSP's static import mechanism. Which JSP code snippet
13. Given the JSP code and the Classic tag handler code:
7. // return int
Which invocation on the pageContext object, inserted at line 6, assigns "bar" to the
variable x?
14. Which implicit object is used in a JSP page to retrieve values associated with
15. Which one of the following exceptions may be thrown by the _jspService()
method?
a. javax.servlet.ServletException
b. javax.servlet.jsp.JSPException
e. None of these
( Word to PDF Converter - Unregistered )
http://www.Word-to-PDF-Converter.net
16. You are writing a JSP that includes scriptlet code to declare a List variable and
initializes that variable to an ArrayList object. Which two JSP code snippets can you
17. You have built a collection of custom tags for your web application. The TLD file
is located in the file: /WEB-INF/myTags.xml. You refer to these tags in your JSPs
using the symbolic name: myTags. Which deployment descriptor element must you
use to make this link between the symbolic name and the TLD file name?
a. myTags/WEB-INF/myTags.xml
b. myTags/WEB-INF/myTags.xml
c. myTags/WEB-INF/myTags.xml
d. myTags/WEB-INF/myTags.xml
18. You need to create a JavaBean object that is used only within the current JSP
page. It must NOT be accessible to any other page including those that this page
might import. Which JSP standard action can accomplish this goal?
a. True b. False
20. Which of the following is a correct JSP declaration for a variable of class
java.util.Date?
a) <%! Date d = new Date() %>
<html><body>
<a href="/servlet/HelloServlet">POST</a>
</body></html>
Assume that there is a HelloServlet servlet Class defined.
Which method of HelloServlet class will be invoked when the hyperlink displayed by
the above page is clicked?
a. doGet() b. doPost() c. doForm() d. serviceGet()
<form action=”/servlet/Login”>
<input type=”text” name=”username” value=”enter username”/>
<input type=”submit” name=”sbbutton” value=”signin!..”/>
</form>
Which of the following happens upon pressing the submit button in the above HTML
form?(Choose 2)
a. A request is sent with the HTTP method GET
c.The parameter username is the only parameter passed to the web server in the request .
d. The parameters username and sbButton are passed to the web server in the
request URL
e. None of these
23. What will be the output of the following partial servlet code?(Choose 2)
}
a) An illegalArgumentException is thrown
24. Smith does not want his programmers to use scripting elements in their JSP
pages. Select from the following, the one correct deployment descriptor
programmers can code to achieve the intended result.
a) <jsp-config>
<jsp-property-group>
<url-pattern>jsp</url-pattern>
<scripting-invalid>
true
</scription-invalid>
</jsp-property-group>
</jsp-config>
b) <jsp-config>
<jsp-property-group>
<url-pattern>jsp</url-pattern>
<scripting-invalid>
false
</scription-invalid>
</jsp-property-group>
</jsp-config>
c) <jsp-config>
<jsp-property-group>
<ur-pattern>*.jsp</url-pattern>
<scripting-valid>
true
</scription-valid>
</jsp-property-group>
</jsp-config>
( Word to PDF Converter - Unregistered )
http://www.Word-to-PDF-Converter.net
d) <jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<scripting-invalid>
true
</scription-valid>
</jsp-property-group>
</jsp-config>
25. What will be the result of running the following jsp file taking into account
that the Web server has just been started and this is the first page loaded by
the server?
<html><body>
<%= request.getSession(false).getId() %>
</body></html>
a) It will not compile
b) It will print the sessionId
c) It will produce a NullPointerException as the getSession(false) method's call
returns null, cause no session had been created.
d) It will produce an empty page
Which one of the following options gives the correct sequence in which the above
steps happen?
a) a,b,c,d,e,f,g
b) a,c,g,f,d,e,b
c) c,g,f,d,a,e,b
d) c,g,d,f,a,e,a
Which one of the following will be the correct outcome of attempting to access the
above JSP for the second time?
31. Data Access Objects does not decouple client interface from underlying data
access mechanics. State True or False.
a. True b. False
32. When you are learning about design patterns, you notice that the Home
interface of an Enterprise Javabean is actually based on one of the patterns. Which
pattern is the Home Interface of an Enterprise Javabean based on?
a) Singleton
b) Session Façade
c) Business Object
d) Factory Method
33. In distributed applications, lookup and exception handling for remote business
components can be complex.When applications use business components directly,
application code must change to reflect changes in business component APIs.
Which of the following intermediate class solves the above problems?
a) Value Object
b) Business Object
c) Business delegate
d) Façade
34. When remote calls are made on the container provided implementations of the
EJBHome and EJBObject, various transactional and security checks are applied
before the call is actually passed on to the bean instance.
Which of the following Design pattern's task does the container provided
implementations of EJBHome and EJBObject perform?
a. Command b. Adaptor c. Bridge d. Façade e. Decorator
35. Your company has a corporate policy that prohibits storing a customer's credit
card number in any corporate database. However, users have complained that they
do NOT want to re-enter their credit card number for each transaction. Your
( Word to PDF Converter - Unregistered )
http://www.Word-to-PDF-Converter.net
management has decided to use client-side cookies to record the user's credit card
number for 120 days. Furthermore, they also want to protect this information
during transit from the web browser to the web container; so the cookie must only
be transmitted over HTTPS. Which code snippet creates the "creditCard" cookie and
adds it to the out going response to be stored on the user's web browser?
36. A developer has created a web application that includes a servlet for each
use case in the application. These servlets have become rather difficult to maintain
because the request processing methods have become very large. There is also
common processing code in many servlets because these use cases are very
similar. Which two design patterns can be used together to refactor and simplify
hide the details of establishing and maintaining remote communications from the
client. In addition, because the business and resource tiers are distributed, the
( Word to PDF Converter - Unregistered )
http://www.Word-to-PDF-Converter.net
application needs to minimize the inter-tier network traffic related to servicing
client requests. Which design patterns, working together, address these issues?
e. None of these
38. A developer is designing a web application that must verify for each
session.
The client has been authenticated.Which design pattern provides a solution in this
situation?
a. Transfer Object
b. Session Façade
c. Intercepting Filter
d. Model-View-Controller
40. Which one of the following options would initialize a stream for sending text to
a browser?
42. When you are learning about design patterns, you notice that the Home
interface of an Enterprise Javabean is actually based on one of the patterns. Which
pattern is the Home Interface of an Enterprise Javabean based on?
a. getMethod()
b. getHeader()
c. getCookies()
d. getInputStream
e. getParameterName()
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class MyFirstServlet extends HttpServlet
{
public void service(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
{
res.setContentType("text/html");
}
package com.evaluvate;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;