Prj321 On Thi

Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

F1 What gets printed when the following expression is evaluated?

Select the one correct


answer.${(1==2) ? 4 : 5}
Answer 5
2 Consider the following HTML page code:
<html><body>
<form name="data" action="/servlet/DataServlet" method="POST">
<input type="text" name="name">
<input type="submit" name="submit">
</form>
</body></html>
Identify the two methods that can be used to retrieve the value of the name parameter
when the form is submitted.
Select one or more:
a. getParameterValue( "name");
b. getParameterValues( "name");
c. getParameters( "name");
d. getParameter( "name");

bd
3 Which JSTL tag likes <%= ... >?Select one:
a. <c:out.print >
b. <c:output >
c. <c:in >
d. <c:out >

d
What is the difference between MVC1 and MVC2?
a.MVC1 is page-centric, MVC2 is controller-centric
b.MVC2 is page-centric, MVC1 is controller-centric
c.The MVC1 process goes from one JSP page to another, while MVC2 directs to a
common panel before directing to another page
d.MVC2 makes use of a system controller while MVC1 doesn't.

c
What are Struts 2 Features? Choose 3
a. Struts 2 Actions are depend on the servlet API
b. Struts 2 Actions are thread safe
c. Any POJO class can be used as Action class.
d. No need of Action forms in Struts 2.
e. Struts 2 allows validation by using the validate() method in Action class.

cde
6 Which of the following statements about the Servlet is false?
Select one:
a.Initialization code in servlets is executed every time the program is made to run
b. Servlets are portable
c. Servlets are easy to use
d. All of the others
e. None of the others

a
7 The deployment descriptor for a stateless session bean that uses the isCallerInRole
method reads as follows:
<security-role-ref>
<role-name>manager</role-name>
<role-link>humanresources</role-link>
<security-role-ref>
<security-role>
<description>
Is allowed to view and update all employee records.
</description>
<role-name>humanresources</role-name>
</security-role>
Which two roles are responsible for creating this deployment descriptor? ( Choose two.)
Select one or more:
a. System Administrator
b. Bean Provider
c. Deployer
d. Application Assembler

bd
8 Which method is used to perform DML statements in JDBC?
a. executeResult()
b. execute()
c. executeUpdate()
d. executeQuery()

c
9 Which of the following methods can be used to add cookies to a servlet response?
Select one:
a. HttpServletResponse.addCookie( String contents)
b. ServletResponse.addHeader( String name, String value)
c. ServletResponse.addCookie( String contents)
d. ServletResponse.addCookie( Cookie cookie)
e. HttpServletResponse.addCookie( Cookie cookie)

e
10 What is the HTTP 1.1 status code that indicates: Everything's fine? Select one:
a. 200
b.101
c.202
d.201

a
11 How does container initialize Servlet Object at deploy time?
a. The servlet must be declared into context deployment descriptor with servlet
tag
b. The servlet must be declared into web deployment descriptor with servlet tag
c. The servlet must be declared into web deployment descriptor with servlet-
mapping tag
d. The servlet does not need to be declared

b
12 What object will represent the output stream for the JSP page?
a. dispatch
b. out
c.response
d.writer

b
13 How do you manage database transaction in JDBC programming?
a. Database transaction management is depends on JDBC driver
b.Database transaction is managed by DBMS server, not by JDBC driver
c.Turn on auto-commit mode to begin transaction, then commit/ rollback
d. Turn off auto-commit mode to begin transaction, then commit/ rollback

d
14 Which is not method of the request object - an instance of HttpServletRequest.
a.sendRedirect(url)
b.getSession()
c.getCookies()
d.getParameterValues(name)

a
15 What are benefits of implements ModelDriven for action class? Choose 2 Select one
or more:
a. All of the others
b.It depends on how many many model objects in application.
c.Struts will then populate the fields of this object with the request parameters, and this
object will be placed on top of the ValueStack once the action is executed.
D.Validation will also be performed on driven model object, instead of the action.

cd
16.You can use the JSTL choose tag to perform conditional processing that's similar to an
if statement only in Java.
Select one:
True
False

F
18 Which of the following is not a directive in JSP?
a. page
b.export
c.include
d.taglib

B
19 Which statement is true if the doStartTag method returns EVAL_BODY_BUFFERED ?
Select one:
a. The doAfterBody method is NOT called.
b. It is never legal to return EVAL_BODY_BUFFERED from doStartTag.
c. The tag handler must implement BodyTag.
d. The setBodyContent method is called once.

D
20 How many numbers are printed, when the following JSTL code fragment is executed?
Select the one correct answer.
<%@ taglib uri=”http://java.sun.com/jsp/jstl/core” prefix=”c” %>
<c:forEach var=”item” begin=”0ʺ end=”10ʺ step=”2ʺ>
${item} </c:forEach>
a. 11
b. 1
c. 5
d. 6

d
b 2
c 2
d 2
21 Which of the following files is the correct name and location of deployment
descriptor ofweb application?. Assume that the web application is rooted at \doc-root.
Select the one correct answer. Select one: Error! Bookmark not defined.

a. \doc-root\dd.xml
b. \doc-root\web.xml
c. \doc-root\WEB_META\web.xml
d. \doc-root\WEB_INF\dd.xml
e. \doc-root\WEB-INF\web.xml

E
22 If ${snapshot} returns a correct connection to the database, the following statement
will display:
<sql:query dataSource="${snapshot}" var="result">
SELECT * FROM Students;
</sql:query>
<c:forEach var="row" items="${result.row}">
<c:out value="${row.stuId}" />
</c:forEach Select one:
a. The list of values of stuId in Students table.
b. Nothing
c. None of the other.
d. An error.

D
23 Which following methods of HttpServlet class stores a resource under the request
URL?
a. doPut
b.doGet
c.doPost
d.doDelete
e.doHead
f.doTrace

A
24 If true value is passed in the ______ element then it suggests that the attribute needs
to be evaluated at the time of request or during run time or dynamically. Select one:
a. required
b. rtexprvalue
c.name
d.attribute

B
25 What is servlet?
a. Servlet is a class that extends the capabilities of the servers and responds to the
incoming
B. Servlet is a web component that is deployed on the server to create a dynamic
web page
c. Servlet is an application deployed on the server to create a dynamic web page
d. Servlet is an interface that must be implemented for creating any Servlet.

C
26 Which of the following statement are correct on Interceptors in Struts2 framework
Select one:
a. Filter can now moved to interceptors, which is more controllable than filters
b. Executes for all the request qualifies for a front controller.
c. All of the others
d. Methods in the Interceptors can be configured whether to execute or not

C
27 Name of the class that includes the getSession method that is used to get the
HttpSession object.
a. SessionContext
b. HttpServletRequest
c.HttpServletResponse
d.SessionConfig

B
28 How to override default configuration of struts 2?
Select one:
a. Override default configuration of struts 2 is not alowwed.
b. Use struts.properties
c. Use custom file name, custom package and register it.
d. None of the others

C
29 According to EJB 2.0 Specification, enterprise beans are restricted from performing
certain operations.
Select one:
a. Extending from a class
b. Creating a client Sockets
c. None of the others.
d. Managing threads

D
30 Which following methods of HttpServlet class returns the HTTP methods the server
supports?Select one:
a. doPost
b.doTrace
c.doDelete
d.doPut
e.doGet
f.doHead

B
31 Consider the following code:
public void doGet( HttpServletRequest req,
HttpServletResponse res)
{
HttpSession session = req.getSession( ); ServletContext ctx = this.getServletContext( ); if(
req.getParameter( "userid") != null)
{
String userid = req.getParameter( "userid");
//1
}
}
You want the userid parameter to be available only to the requests that come from the
same user. Which of the following lines would you insert at //1?
Select one:
a. req.setAttribute( "userid", userid);
b. ctx.addAttribute( "userid", userid);
c. session.setAttribute( "userid", userid);
d. session.addAttribute( "userid", userid);

C
32 What happen when cookie is not allowed on client browser? Choose 2
a. URL rewrite can be used instead of cookie()
b.Client data stored in session but sessionID is not available in cookie
c.Web application will not work properly if cookie is disable on browser.
d.Client data will not be stored in session

AB
33 In EJB 2.x, select the correct steps to use an EJB.
Select one:
a. 1)Look up a home object 2)Use the home object to create an EJB object 3)Call
business methods on the EJB object 4)Remove the EJB object
B.1)Look up a home objec 2)Call business methods on the EJB object 3)Use the home
object to create an EJB object 4)Remove the EJB object
C.1)Look up a home object 2)Use the home object to create a bean instance 3)Call
business methods on the bean instance 4)Remove the bean instance
D.1)Look up a remote object 2)Use the remote object to create an EJB object 3)Call
business methods on the EJB object 4)Remove the EJB object

A
34 Which components are required to use custom tag in JSP pages?
a. Custom taglib class that extends from Struts2, xml file
Custom taglib class that extends from tagext, tld file, declaration in web deployment
descriptor
Custom taglib class that extends from tagext, tags file, declaration in both web.xml and
JSP files
Custom taglib class that extends from JSTL, tld file, declaration in context.xml file

B
35 If ${snapshot} returns a correct connection to the database, the following statement
will display:
<sql:query dataSource="${snapshot}" var="result">
SELECT * FROM Students;
</sql:query>
<c:forEach var="row123" items="${result.rows}">
<c:out value="${row.stuId}" /> </c:forEach Select one:
An error.
The list of values of stuId in Students table.
None of the other.

A
36 A ________has a name, a single value, and optional attributes such as a comment,
path and domain qualifiers, a maximum age, and a version number. Select one:
a. cookie
b.response
c.request
d.session
A

37 How do you define a custom tag in JSP page?


a. All of others
b.Create tag handler class and declare it in TLD file
c.Using taglib directive in JSP page with uri and prefix attribute
d.Define a tag library descriptor – TLD file – in WEB-INF.

A
38 _____ provides a way to identify a user across more than one page request or visit to
a Web site and to store information about that user. Select one:
a. Cookie
b.URL Rewrite
c.Hidden Field
d. Session management

D
39 Which method we must override in the extend ActionSupport class to provide the
implementation of validation in Struts 2?
a. input() method
b. validate() method
c.checkParams() method
d.validate() method for each input data

B
40 Which tag executes the SQL query defined in its body or through the sql attribute?
Select one:
a.<sql:executeQuery>
b.<sql:update>
c. <sql:query>
d. <sql:executeUpdate>

C
You cannot use the JSTL forEach tag to loop through most types of collections, including
regular arrays.
Select one:
True
False

F
Life-cycle methods of a servlet
a. doGet(), doPost(), doHead()
b. init(), doFilter(), destroy()
c. init(), service(), destroy()
d. init(), doGet(), doPost(), destroy()
C
43 You can use the test attribute to specify the Boolean condition for the if statement in
JSTL.
Select one:
True
False

T
45 The login page in basic security prompts the user for _____ Select one:
Password and Encryption
User-ID and password
Identical and Signature
None of the others.

B
47 Which JSTL tag sets a parameter in an SQL statement to the specified value? Select
one:
a. <sql:param>
b.<sql:parameter>
c.<sql:setparameter>
d.<sql:setparam>

A
48 What are the requirements of a message-driven bean ( EJB 3.x) class? ( Select three)
Select one or more:
a.It implements receive( ) method
b.It implements onMessage( ) method
c.It implements the MessageListener interfaces
d.It is annotated with @MessageDriven annotation

BCD
49 What are components of Struts 2 framework?
a. Action Classes – ActionInvocation
b.Struts-Tag Libraries
c.JUnit plugin
d.JSTL
e. ValueStack,OGNL

E
50 The Struts Framework is a standard for developing well-architected Web applications,
it has the following features?
Select one:
a.Implement the JSP Model 2 Architecture
b.Model View Controller
c. All of the others
d. Open Source

C
51 Which of the following code is used to get an attribute in a HTTP Session object in
servlets?
a. session.setAttribute(String name)
b. session.alterAttribute(String name)
c. session.getAttribute(String name)
d. session.updateAttribute(String name)

C
52 Assume the product attribute does NOT yet exist in any scope. Which two create an
instance of com.example.Product and initialize the name and price properties to the
name and price request parameters? ( Choose two.) Select one or more:
A <jsp:useBean id="product" class="com.example.Product" /> <% product.setName(
request.getParameter( "name" ) ); %> <% product.setPrice( request.getParameter(
"price" ) ); %>
B <jsp:useBean id="product" class="com.example.Product"> . <jsp:setProperty
name="product" property="name" value="${name}" />
<jsp:setProperty name="product" property="price" value="${price}" />
</jsp:useBean>
C<jsp:useBean id="product" class="com.example.Product" /> . <jsp:setProperty
name="product" property="name" value="${param.name}" />
<jsp:setProperty name="product" property="price" value="${param.price}" />
D<jsp:useBean id="product" class="com.example.Product" /> . <jsp:setProperty
name="product" property="*" />

AB
53 CRUD stands for:
a. concurrency, ready, update, and dependency
b. create, read, update, and delete
c.create, read, upload, and download
d.connect, read, update, and delete

B
54 You can use the JSTL forTokens tag to loop through items in a delimited string. Select
one:
True
False

T
55 Which of the following is not correct on Web Deployment Descriptor?
a.The root element of web.xml is
b.The load-on-startup element of servlet in web.xml is used to load the servlet at the
time of deploying the project or server start
c.Web.DDL stand for Web Deployment Descriptor
d.If a web app has no web.xml, then web server apply the default file

C
56 Which of the following methods must be overridden in Action class? Select one:
a.dofilter()
b.destroy()
c. init()
d. execute()

D
57 Which followings are INVALID requirements for FORM authentication?
Select one:
a.The form must have “j_security_check” as its action.
b.The form must include an input-capable field for user called “j_username.”
c.The form must also include an input-capable field for password called “j_password.”
d.The HTML form must use the GET method.

D
58 Your servlet class depends on a utility class named com.abc.TaxUtil. Where would
you keep the TaxUtil.class file?
Select one:
a.WEB-INF/jars
b.WEB-INF/lib
c.WEB-INF
d.WEB-INF/classes
e. WEB-INF/classes/com/abc

E
59 Which of the following statement(s) regarding Struts 2 framework are true?
a. Struts 2 framework is an extension of Struts framework.
b. Struts 2 framework supports the development of persistence logic in the
enterprise applications.
c. In Struts 2 framework, the component information is configured in struts.xml
file.
d. Struts 2 is an extensible framework can be easily integrated with any other
frameworks.
e. Struts 2 is based on a pull-MVC framework.
a. ACE
BCD
ADE
ACD

A
70 Which of the following tasks that can be performed using JDBC in Java?
a.Operate the database transactions.
b.Request the JDBC connection from the server manager.
c.Get the results from database.
d. Leave the JDBC connection open.
a. BC
AD
AB
AC

D
71 Which of the following are required for developing java web application?choose 3
a.Java Development Kit
b.Database server
c.Operating system
d.Java web server

D
72 With respect to the GET of the HTTP method, parameters of a request will be put in
its .......
a. request headers.
b.separate part.
c.request line.
d.request body.

A
73 Which syntax is correct for JSP Declarations?
Select one:
a.None of these
b.<% code %>
c.<%! code %>
d.<%= code %>

C
74 What gets printed when the following expression is evaluated? Select the one correct
answer.$
{
~1
~2
~4
=5
}
$ { ~1 ~2 ~4 =5 }

76 What is the purpose of @UrlValidator annotation?


a.This annotation checks that a String field is not empty
b.This annotation checks that a field is a valid URL.
c.This annotation checks that a String field is of the right length.
d.This annotation checks that a field is non-null.

B
77 Which one of the following must be done before authorization takes place? Select
one:
a. Auditing
b.User authentication
c.Data validation
d.Data encryption
e.Data compression

B
78 Which security mechanism proves that data has not been tampered with during its
transit through the network?
Select one:
a.Data validation
b.Data privacy
c.Data integrity
d.Packet sniffing
e.Authentication
f.Authorization
C
Before you can use JSTL tags within a JSP, you must code a import directive that
identifies the JSTL library and its prefix.
True
False

F
Which method in Action class is executed when request comes? Choose 2
a. execute() is calling by default
b.Any method with no argument and define by action mapping
c.Any method define by action mapping.
d.Only execute() method

AB
81 Java web application can not be deployed on
a. Tomcat
b.Jboss
c.IIS
d.Websphere

C
82 What is servlet? (Choose 2)
a. Servlet is a class that extends the capabilities of the servers and responds to the
incoming requests. It can respond to any requests
b. Servlet is an interface that must be implemented for creating any Servlet.
c. Servlet is used in View layer of MVC model.
d. Servlet is a web component that is deployed on the server to create a static web
page

AB
83 Which of the following components is used by application to work with database
server?
a. Statement
b.JDBC driver
c.Connection
d.DriverManager

C
84 In web.xml file, which of the following elements is used to configure the timeout for
sessions generated in the web application?
a. <timeout> timeout </timeout>
b.It is not allowed to specify timeout for sessions in web.xml
c.<session-timeout> timeout </session-timeout>
d.<session> timeout </session>

C
85 The following statement is true about which type of EJB?
"All bean instances are equivalent when they are not involved in serving a client-invoked
method”
Select one:
a. Stateful session bean.
b. Entity bean with bean managed persistence.
c. Stateless session bean
d. Entity bean with container managed persistence.

C
86 What is the return type of the getLastModified method of HttpServlet?
a. long
b.java.sql.Date
c.int
d.java.util.Date

A
87 Which is not true about Filter?
a. A filter is an object that is invoked at the preprocessing and postprocessing of a
request
b. The servlet filter is pluggable, i.e. its entry is defined in the web.xml file
c. Filter is a servlet – controller.
d. Mainly used to perform filtering tasks such as conversion, logging, compression,
encryption and decryption, input validation etc

D
88 Where do you close database connection in JDBC programming?
a. No need to close connection as JVM automatically close it after used.
b. Close connection in try block of try – catch - finally
c. Connection is autoclose if we getConnection() in try(getConnection())
d. Close connection in finally block of try – catch – finally
D
89 In the request life cycle of Struts 2, which component invokes the Interceptors to
apply the common functionalities?
a. ActionMapping
b.ActionServlet
c.ActionInvocation
d.FilterDispatcher

C
90 Which of the following error code is associated with the message "Resource not
found”?
a. 500
b.404
c.401
d.403

B
91 Action classes are the components of Select one:
a. View
b.Deployment
c.Model
d.Controller

C
92 Which statements about JDBC are NOT true?
a. It consists of a set of classes and interfaces written in the Java programming
language.
b. JDBC provides a standard API for tool/database developers and makes it
possible to write database applications using a pure Java API.
c. The combination of Java and JDBC lets a programmer write it once and run it
anywhere.
d. JDBC is a Java database system.

D
93 Which is a benefit of precompiling a JSP page?
Select one:
a. It avoids execution of the _jspService method on the first request.
b. It provides the ability to debug runtime errors in the application.
c. It avoids initialization on the first request.
d. It provides better performance on the first request for the JSP page.
D

94 Does Struts2 mandates of implementing the Action interface in action classes to have
the default Action method (execute)?
Select one:
a. Yes, action class must implement it to have the execute method overriden in the
action classes
b. No, Struts2 doesn't mind if the action classes doesn't implement the Action interface,
but requies the execute method executed on default action method selection

B
95 Which of the following descriptions most closely matches what happens when a tag
file is used for the first time?
Select one:
ANone of the others
B. The tag file is located, and source is generated into a class which implements the
SimpleTag interface, then compiled. The calling JSP makes calls to SimpleTag life cycle
methods
C The tag file is located, and its source is included in the calling JSP. The combined
source is treated as a translation unit and generated into servlet source, which is
compiled
D The tag file is located, and its source is used for the generation and compilation of a
separate servlet invoked from the calling JSP

B
96 What are differences between Pull-MVC and push-MVC based architecture ?
Select one:
a. Pull-MVC means transfer data from client to server, whereas Push MVC means
render data from server to client by View.
b. Push-MVC means transfer data from client to server, whereas Pull MVC means
render data from server to client by View.
c. The difference on how the view layer is getting data to render. Struts 1 is Push d.
MVC while Struts 2 is PULL MVC
d. None of the others

C
97 What are true on ValueStack?
Select one:
a. All of the others.
b. When a request come an object of ValueStack is created first and after it object
of Action, Model or any other java resources are created
c. Retrieve via ActionContext.getContext().getValueStack()
d.In struts 2 ValueStack represents a stack that contains the references of application
specific objects.
e.It contains the maps of object like Request Parameters, Request Attributes, Session
Attributes and Application Attributes.

A All of the others.

98 Which is not true about Custom tags?


a. Perform server-side work based on the tag’s attributes
b. Define a server-side object that is available in the rest of the page, based on its
attributes
c. Produce output
d. A custom tag must have start tag, a body, and end tag

D
99 Which of the following statement are more efficient due to pre-compilation of SQL?
a. PreparedStatement
b.Statement
c.CallableStatement
d.DriverManager

AC
102 You are given a tag library that has a tag named printReport. This tag may accept an
attribute, department, which cannot take a dynamic value. Which of the following are
correct uses of this tag? ( Select two) Select one or more:
a. <mylib:printReport><jsp:attribute name="department" value="finance"
/></mylib:printReport>b. <mylib:printReport attribute="department" value="finance"/>
c. <mylib:printReport department="finance"/>
D.<mylib:printReport/>
E.<mylib:printReport attribute="department" attribute-value="finance"/>

CD
103 A CMP bean must be declared as ...........
Select one:
a. a public abstract class.
b. None of the others.
c. an inteface.
d. a concrete class because it associates with a specific table in a specific database.

A
104 Choose correct statement on custom tag:
a. Only session object available inside tag handler class.
b. Custom tag handler class reference implicit objects via JspContext
c. Custom tag handler class can not reference implicit objects in JSP page
d. Implicit objects is automatically available inside tag handler class

B
105 The <jsp:include/> action can pass parameters to the page which it is included. How
does this second page obtain the value of these parameters?
Select one:
a. Use the request.getParameter( ) method
b. All of the others.
c. Use the action

A
106 Which of following feature does indicate “Servlet should NOT use as dynamic
page”?
a. Initialize only once at deploy time
b. Automatically connect to the Database
c. Low lever HTML format
d. Getting auto refresh on receiving a request time

C
108 This method run smoothly without any runtime error. What will be wrong with it?
public int doSomething() throws Exception{
Class.forName(driverName);
Connection con= DriverManager.getConnection(dburl,us,pw) ; Statement stmt=
con.createStatement(); return stmt.executeUpdate(“Update account set
balance=balance*0.01 where balance>=100000”);
}
A. Nothing wrong
B. There will be resource leaking as connection did not close after work.
C. The method can return 0 if there is no balance>=100000
D. Exception should be catched instead of throwing.

B
109 Consider the following code and select the correct statement about it from the
options below. <html><body>
<%! int aNum=5 %>
The value of aNum is <%= aNum %>
</body></html> Select one:
A. It will flag a compile-time error because of an incorrect declaration.
B. It will not flag any compile time or runtime errors and will not print anything to
the output.
C. It will throw a runtime exception while executing the expression.
D. It will print "The value of aNum is 5" to the output.

A
110 Which of the following method should not be overriden in JSP?
a. jspDestroy()
b. jspService()
c.doGet() – doPost()
d.jspInit()

B
111 Which file contains java script for client side validation using validation framework
in struts?
a. both files
b.validator-rules.xml
c.None
d.validation.xml

B
112 Which Custom tag is used to dynamically add the contents from the provided URL to
the current page at request time?
a. <c:embedd=8ed>
b. <c:content>
c. <c:import>
d. <c:include>

C
115 What is the role of Action/ Model in Struts 2 Framework?
Select one:
a. The role of Action is to execute business logic
b. All of the others
c. Helps the framework decide which result to render
d. Delegate call to business logic by the means of action methods which is mapped
to request and contains business data

B
116 What is the output from the following JSP?
<%! String s = "final"; %>
EL: ${s}
Scriptlet: <%= s %>
<% Integer test = new Integer(8); request.setAttribute("num", test); %>
EL: ${num}
A. EL: Scriptlet: EL: 8
B. EL: final Scriptlet: final EL: 8
C. EL: Scriptlet: final EL: 8
D. EL: final Scriptlet: final EL: 8

C
117 What causes "No suitable driver" error?
A. Too many driver loaded.
B. It can be specifying an invalid JDBC URL, one that is not recognized by JDBC
driver
C. This error can occur if one or more the shared libraries needed by the driver
cannot be loaded
D. Due to failing to load the appropriate JDBC drivers before calling the
getConnection method

C
118 Which of the following is not JSP Implicit variable?
A. response
B. request
C. exception
D. httpSession
E. page
F. application

D.
119 Which is correct syntax of JSTL action tag to include a resource into current page?
a. <c:import uri=”http://abc.jsp”/>
b.<c:import url=”abc.jsp”/>
c.<c:import url=”abc.jsp” var=”test”/>
d.<c:import var=”test”/>

B
120 a. There is no way for user send request to such servlet if jsp/html is not used – the
role of
View
b.No way, there must be jsp page for input form to send request to servlet. Servlet can
only be a Controller.
c.As a request send to servlet, doGet() will present input form for user login then
doPost() will process login data. This is not MVC architecture.
d.There must be an object – model class- help the servlet to access database for login
processing.
121 Which of the following is correct about PreparedStatement?
A. Prepared statements use bind arguments, which are sent to the database
engine.
B. Prepared statements reuse the same execution plan for.
C. Prepared statements reuse the same execution plan for different arguments
rather than creating a new execution plan every time
D. Prepared statements offer better performance, as they are pre-compiled

b
122 In the Action interface which constant indicates that action execution is successful
but no result should be shown to the user? Select one:
A.LOGIN
b. INPUT
c. NONE
d. SUCCESS

C
123 What does the FilterChain do?
A. It invokes the first filter in the chain.
B. It invokes the next filter in the chain, or if the calling filter is the last filter in the
chain, it invokes the resource at the end of the chain.
C. It does nothing.
D. FilterChain is a function of the web.xml file

B
124 A ___________ subscription to a topic means that a JMS subscriber receives all
messages, even if the subscriber is inactive.
Select one:
a. nondurable
b. durable
c.permanent
d.temporary

B
125 The class java.sql.Timestamp has its super class as
a. java.sql.Time
b.java.sql.Date
c.java.util.Date
d.java.util.Time
C

126 Which of following statement are true about EL and OGNL? Choose 3.
Select one or more:
A. EL interacts with the objects by means of getters/setters, OGNL supports
whatever EL does along with lambda experssion,
B. Struts application can use OGNL or EL in JSPs
C. Struts application can only use OGNL in JSPs
D. OGNL stands for Object graph navigation language,which is used internally by
Struts2

ABD
127 What are two principal methods to manage session?
Select one or more:
a. request
b.URL rewriting
c.response
d.Cookie
e.HTML field

BD
128 What is the relation between ValueStack and OGNL ?
Select one:
A ValueStack is a place where all the data related to action and the action itself is stored.
OGNL is an expression language.
ValueStack and OGNL are 2 components in Struts 2 Framework
All of the others
D.A ValueStack is a place where all the data related to action and the action itself is
stored, while OGNL is a mean through which the data in the ValueStack is manipulated.

D
129 Which of the following interfaces or classes is used to retrieve the session
associated with a user?
Select one:
a. HttpServletRequest
b. ServletContext
c. HttpServlet
d. ServletConfig
e. HttpServletResponse

A
130 What method must be implemented to receive messages in a message-driven bean
( MDB)? Select one:
a. The processMessage method
b. The readMessage method
c. The receive method
d. The onMessage method

D
131 What of the following are correct on Get and Post method?
a. Un-limited data upload for both get and post method
b.Get is not Secured because data is exposed in URL bar
c.Large amount of data can be sent in body of Get method
d.Post can be bookmarked

B
132 Entity bean is _______ Select one:
a. a database object
b. an object-relational mapping
c. a persistent data component
d. an application logic component

C
133 Which is NOT the party that need involved in the EJB Ecosystem?
Select one:
a.Bean Provider
b.EJB Deployer
c.System Administrator
d. End users
e. Application Assembler

D
134 Given the following statements about an EJB deployment descriptor for which the
metadata-complete attribute is not specified:
I. The EJB deployment descriptor can provide additional metadata to bean
class annotations.
II. The EJB deployment descriptor can partially override bean class
annotations.
III. The EJB deployment descriptor can entirely override bean class annotations.
Which is true?
Select one:
a. Only statement III is correct.
b. Only statement I is correct.
c. Both statements I and III are correct.
d. Both statements I and II are correct.
e. Only statement II is correct.

D
135 JSTL stands for Select one:
a. JavaServer Pages Standard Tag Library
b. Servlet Pages Standard Tag Library
c. JavaBean Standard Tag Library
d. Enterprise JavaBean Standard Tag Library

A
136 _______ includes a static file in a JSP file, parsing the file's JSP elements (choose the
most correct one) Select one:
a. <jsp:forward>
b. <jsp:include>
c. <jsp:useBean>
d. import directive
e. include directive

E
137 To connect to the database, which JSTL tag do we use?
Select one:
a. <sql:setDataSource>
b. <sql:setConnection>
c. <sql:setDataBase>
d. <sql:setDatabase>

A
138 Which statement( s) is( are) applied during JSP page translation?
Select one:
a. The JSP page is validated for syntactic correctness
b. The associated tag files are validated for syntactic correctness
c. All of the others
d. The JSP page implementation class is created

C
139 Before you can use JSTL tags within an application, you must make the jstl-impl.jar
and jstlapi.jar files available to the application.
Select one:
True
False

T
140 In a Java web application, how does login task provide to user with just only one
servlet?
A. There is no way for user send request to such servlet if jsp/html is not used – the
role of View
B. No way, there must be jsp page for input form to send request to servlet. Servlet
can only be a Controller.
C. As a request send to servlet, doGet() will present input form for user login then
doPost() will process login data. This is not MVC architecture.
D. There must be an object – model class- help the servlet to access database for
login processing.

C
141 Which implicit object is supported in jsp page to access pageScope, requestScope,
sessionScope, applicationScope?
a. scope object
b.pageContext object
c.context object
d.application object

B
142 Choose correct statement on JSTL (choose 2)
A. JSTL can be used for ordinary view, but not for JDBC access to database
B. JSTL includes tag library that can be use in JSP without any instalation.
C. JSTL provides a framework for integrating the existing custom tags with the JSTL
tags
D. JSTL has support for common, structural tasks and conditionals, tags for
manipulating XML documents, internationalization tags, and SQL tags

CD
143 Given a web application in which the request parameter productID contains a
product identifier. Which TWO EL expressions evaluate the value of the productID?
Select one or more:
A. ${param.productID}
B. ${params.productID[1]}
C. ${paramValues.productID[0]}
D. ${paramValues.productID}
E. ${params.productID}

AC
If necessary, you can nest one JSTL if tag within another.
Select one:
True
False

T
Which Design Pattern does Struts2 Framework apply?
a. MVC 2 using DAO add Connect Database
b. MVC 2 using Filter as Controller
c.MVC 2 using Servlet as Controller
d.MVC 2 using Data Transfer Object as Controller

B
146 In which configuration file is a link between the View and Model components in the
Web Client but you would not have to touch these settings for 99.99% of your projects?
Select one:
a. The web.xml file
b. The struts-config.xml file
c. The struts.properties file
d. The struts.xml file

B
147 Message Driven Beans ( MDBs) can be pooled by the EJB container. Select one:
a. True
b. False

T
You cannot nest one JSTL choose tag within another.
Select one:
True
False

F
You can use the JSTL for tag to loop through most types of collections, including regular
arrays. Select one:
True
False

F
Which class is the front-controller in Struts2 ?
Select one:
a. org.apache.struts2.dispatcher.FilterDispatcher
b. org.apache.struts2.dispatcher.ActionFilter
c. It depends on the version of Struts 2 implementation that can be
FilterDispatcher or
StrutsPrepareAndExecuteFilter
d. org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

151 Assume the product attribute does NOT yet exist in any scope. Which two create an
instance of com.example.Product and initialize the name and price properties to the
name and price request parameters? ( Choose two.) Select one or more:
A. <jsp:useBean id="product" class="com.example.Product"> .
<jsp:setProperty name="product"
property="name"
value="${name}"
/>
<jsp:setProperty name="product" property="price" value="${price}" />
</jsp:useBean>
<jsp:useBean id="product" class="com.example.Product" /> .
<jsp:setProperty name="product" property="*" />

<jsp:useBean id="product" class="com.example.Product" /> .


<jsp:setProperty name="product" property="name" value="${param.name}" />
<jsp:setProperty name="product" property="price" value="${param.price}" />

<jsp:useBean id="product" class="com.example.Product" /> <% product.setName(


request.getParameter( "name" ) ); %>
<% product.setPrice( request.getParameter( "price" ) ); %>

152 Your web application requires the ability to load and remove web files dynamically
to the web container's file system? Which two HTTP methods are used to perform these
actions? ( Choose two) Select one or more:
A. REMOVE
B. POST
C. DELETE
D. SEND
E. PUT

CE
153 Which of the following tags in jsp file defines the availability of necessary Struts JSP
custom tag libraries? Select one:
a. jsp-taglib
b. taglib
c. struts-taglib
d. jsp-lib

B
154 Identify the correct order of phases in the Public/Private Key encryption?
1. Server provides its public key
2. Client makes request for secure resource
3. Server provides secure resource, encrypted with the client's public key
4. Client provides its public key, encrypted with the server's public key Select one:
2–1–4–3
2–4–3–1
3–1–4–2
1–2–3–4

A
155 Which element is the parent of the <filter> tag in the web application deployment
descriptor?
a. <filters>
b. <filter-list>
c. <servlet>
d. <web-app>

D
156 Study the statements:
1)Every web application within a web container has a unique context path.
2)The context path and any directories you choose to create within it contain resources
that are accessible through HTTP.
Select one:
a. Both 1 and 2 are true.
b. Both 1 and 2 are not true.
c. Only statement 2 is true.
d. Only statement 1 is true.

A
157 A servlet sets a session-scoped attribute product with an instance of
com.example.Product and forwards to a JSP. Which two output the name of the product
in the response?
Select one:
a. <jsp:useBean id="com.example.Product" /> <%= product.getName( ) %> b.
B. ${product.name}
C.<jsp:getProperty name="product" class="com.example.Product" property="name" />
D.<jsp:useBean id="product" type="com.example.Product"> . <%= product.getName( )
% </jsp:useBean>

B
_______ are small pieces of information that are deposited on the client by the server.
a.Scriptlet
b.Session
c.Directive
d.Cookie

D
What is a web application? (choose 2)
a.Application installed on a web server.
b.Any computer software that follow HTTP protocol
c.Any website is a web application.
d.Dynamic website where user can create data.

AD
How do you create and using filter?
a.Let your filter participate in filter chain
b.Mapping filter to url, resourse in web.xml
c.Define filter class implements interface Filter
d.Automatically created by web server

B
What is a benefit of bean pooling in an EJB container?
a.It reduces the memory allocation and garbage-collection cycles.
b.All of the others
c.It does not need supporting from server
d.It increases the memory allocation and garbage-collection cycles.

A
Following is the syntax to include ___________in your JSP
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
a.JSTL Formatting library
b.JSTL Core library
c.JSTL SQL library
d.JSTL XML library

C
What are the types of messaging models supported in JMS? (Choose two)
a.Point-to-point
b.Send/receive
c.Transmit/receive
d.Publish/subscribe

AD
164. Which services are the container provided?
1. Transactions
2. Securities
3. Persistence
4. Location translation
5. Process and Thread Management Select one:
1, 3, 5
1, 2, 3
1, 2, 3, 4, 5
1, 2, 4, 5

B
165. Which is not true about Custom tags?
b. A custom tag must have start tag, a body, and end tag

B
166. Which of information are needed when declaring the web resource collection in the
deployment descriptor?
A. The URL pattern that requires authorization
B. The users allowed access to the web resource
C. None of the others
D. The authentication mechanism required by the web resource.

A
The Directory Structure of web application on different java web servers are:
a.Not the same and depend on specific web server
b.Depend on web development tool
c.Depend on IDE tool.
d.All the same on any java web server

D
The following statement is true about which type of EJB?
"All bean instances are equivalent when they are not involved in serving a client-invoked
method”
a.Stateless session bean
b.Stateful session bean.
c.Entity bean with bean managed persistence.
d.Entity bean with container managed persistence.

A
Which are true about Struts 2 Session management? Choose 2 Select one or more:
a. Session in Struts 2 Framework constructed by SessionMap, actually is Map<String,
Object>
B. Retrieve session in Struts 2 via ActionContext class or implements
SessionAware
Session in Struts 2 Framework is HttpSession
Retrieve HttpSession in Struts 2 via ActionContext class or implements SessionAware.

AB
170 The ________ method returns a string containing the value of the named
initialization parameter
a.getServletConfig()
B. getInitParameter()
C. jspInit
D. init()

B
171 You can use the JSTL if tag to perform conditional processing that's similar to an if
statement in Java.
True
False

A
172 Which of the following is true about Enterprise JavaBeans ( EJB 3.x) objects?
Select one:
a. The home interface is no longer required.
B.The bean must be defined in the XML deployment descriptor.
C.The bean class implements the EJBInterface class.
D.The remote interface, or the EJBObject interface, typically provides method signatures
for business methods.

A
173 How many objects of a servlet is created for request from clients?
a. Only one
b.Depends on the number of request from clients
c.Depends on servlet container
d.One per client

A
Which is true about TLD files?
a.TLD files may be placed in any subdirectory of WEB-INF.
b.TLD files can declare both Simple and Classic tags, but TLD files are NOT used to
declare Tag files.
c.TLD files may be placed in the META-INF directory of the WAR file.
d.TLD files are used to configure JSP environment attributes, such as scripting-invalid.

A
Which of the followings is a correct way to pass a parameter equivalent to the query
string user=mary at request time to an included component?
Select one:
A. <jsp:include page="other.jsp"><jsp:param user="mary" /></jsp:include>
B. <jsp:include page="other.jsp"><jsp:param name="mary" value="user"
/></jsp:include>
C. <jsp:include page="other.jsp"><jsp:param paramName="user"
paramValue="mary"
/></jsp:include>
D. <jsp:include page="other.jsp"><jsp:param value="mary" name="user"
/></jsp:include>
E. <jsp:include page="other.jsp"><jsp:param param="user"
value="mary"/></jsp:include>

D
176 Which of the following methods is used for redirecting requests?
a.sendRedirect()
b.getHeader()
c.RequestDispatcher()
d.redirectRequest()

A
177 The test.jsp contains the following code. <%!
String s = "String 1";
public void check() {
System.out.println("this is check function");
}
%>
<%
check();
public void checkJSP() {
System.out.println("this is check JSP function");
}%>

What is the output?


a.The program gives a syntax error because of the statement "public void checkJSP() {"
b.The server display " this is check JSP function "
c.The program gives a syntax error because of the statement "public void check() {"
d.The server display "this is check function"

A
Which of the following statements about the JavaBean is true
a.The public methods give access to the properties of the bean.
b.JavaBean component property must only be write-only format.
c.It is impossible initialise the JavaBeans with arguments using jsp:useBean.
d.JavaBean is an object initialization method

A
Which of the following is correct about dispatcher result type?
a.It is used to generate output using predefined templates
b.None of the above
c. It calls the standard response.sendRedirect() method, causing the browser to create a
new request to the given location
d.It is used to forward to a servlet, JSP, HTML page, and so on, on the server. It uses the
RequestDispatcher.forward() method

D
Which of the following is not a part of Struts architecture?
a.Actions
b.Value Stack / OGNL
c.Interceptors
d.EJB

181.which of the following statements about the javaBean is true


The public methods give access to the properties of the bean.
182. In a Java web application, how does login task provide to user with just only one
servlet?
As a request send to servlet, doGet() will present input form for user login then
doPost() will process login data. This is not MVC architecture.

183. What is the difference between <jsp:forward page = ... > and
response.sendRedirect(url)?
Choose 2
a.<jsp:forward> is dynamic action, response.sendRedirect(url) is not
b.The <jsp:forward> forwards the request with client data, but sendRedirect(url) does
not send
client
data.
c.<jsp:forward> make change from server side, sendRedirect(url) make change to client
side.
d.Both are the same symantic and functionality

184. If ${snapshot} returns a correct connection to the database, the following


statement will display:
<sql:query dataSource="${snapshot}" var="result">
SELECT * FROM Students;
</sql:query>
<c:forEach var="row" items="${result.rows}">
<c:out value="${row.stuId}" />
</c:forEach
Select one:
a. Nothing
b.The list of values of stuId in Students table.
c.An error.
d.None of the other.

B
185. If ${snapshot} returns a correct connection to the database, the following
statement will display:
<sql:query dataSource="${snapshot}" var="result">
SELECT * FROM Students;
</sql:query>
<c:forEach var="row" items="${rows}">
<c:out value="${row.stuId}" />
</c:forEach Select one:
a.None of the other
b. An error.
c.Nothing
d.The list of values of stuId in Students table.

You might also like