SampleExam15(Ch39-43.. - College of Engineering and Computer

advertisement
Name:_______________________ Sample Exam
Covers Chs 39-43
Multiple Choice Questions Only for This Test
Part I: Questions: (1 pts each)
1 Every doXxx method in the HttpServlet class has a parameter
of the __________ type, which is an object that contains
HTTP request information, including parameter name and
values, attributes, and an input stream.
A.
B.
C.
D.
HttpServletResponse
HttpServletRequest
HttpSession
Cookie
2 To start the Tomcat servlet engine, use the command
__________ from the TomcatRootDir\bin directory.
A.
B.
C.
D.
start
startup
start Tomcat
java TomcatServlet
3 Which of the following creates a check box in an HTML form?
A. <input type="radio" name="gender" value="M" checked>
B. <textarea name="remarks" rows="3" cols="56"></textarea>
C. Major <select name="major" size="1"> <option
value="CS">Computer Science<option
value="Math">Mathematics<option>English<option>Chinese</sel
ect>
D. <input type="checkbox" name="tennis"> Tennis
E. <input type="text" name="mi" size="1">
4 _________ is a subinterface of ServletRequest.
A.
B.
C.
D.
Servlet
HttpServletRequest
HttpServletResponse
HttpServlet
5 You can use __________ to implement session tracking in
servlets.
A. the Cookie class
B. HTML hidden values in a form
C. the HttpSession class
1
6 The _________ interface defines the methods that all
servlets must implement.
A.
B.
C.
D.
HttpServlet
ServletResponse
javax.servlet.Servlet
ServletRequest
7 Before starting Tomcat, you have to set the environment
variable JAVA_HOME to _______
A.
B.
C.
D.
JDKHomeDir/java
JDKHomeDir/bin/java
JDKHomeDir/bin
JDKHomeDir
8 The code for loading a JDBC driver and connecting to a
database should be invoked from _____ in a servlet.
A.
B.
C.
D.
the doPut method
the init method
the destroy method
the doGet method
9 Every doXxx method in the HttpServlet class has a parameter
of the HttpServletResponse type, which is an object that
assists a servlet in sending a response to the client.
A.
B.
C.
D.
HttpSession
Cookie
HttpServletResponse
HttpServletRequest
10 Apache Tomcat is a ________.
A.
B.
C.
D.
Servlet
Java program
Web server
Web server that is capable of running Java programs.
11 For an instance of Cookie, say cookie, to retrieve the name
of the cookie, use ____________.
A. cookie.getVlaue()
B. cookie.getName()
C. You have to use cookie.getValues() to obtain all values in an
array.
D. You have to use cookie.getNames() to obtain all values in an
array.
2
12 If your servlet class file does not have a package
statement, the servlet .class file must be placed in
________ by default.
A.
B.
C.
D.
TomcatRootDir\webapps\examples\WEB-INF
TomcatRootDir\webapps\WEB-INF\classes
the same directory with the .java file.
TomcatRootDir\webapps\examples\WEB-INF\classes
13 Suppose the two parameters in the doGet or doPost method is
request and response. To send output to a client, create a
PrintWriter using _____________.
A.
B.
C.
D.
response.getWrite()
response.writer()
response.getPrintWriter()
response.getWriter()
14 The _______ method is called when the servlet is first
created, and is not called again as long as the servlet is
not destroyed.
A.
B.
C.
D.
service
destroy
init
getServletInfo
15 In a URL query string, the parameter name and value are
associated using the ____ symbol.
A.
B.
C.
D.
E.
=
?
+
&
16
JSP files end with __________.
A.
B.
C.
D.
.shtml extension
.html extension
.java extension
.jsp extension
17 Which of the following statements are true?
A. JSP is translated into HTML by a Web server when a JSP is
called.
B. JSP is translated into Java servlet by a Web server when a JSP
is called.
3
C. YOu can embed Java code in JSP.
D. JSP is translated into XML by a Web server when a JSP is
called.
18 _______________ is a JSP declaration.
A. <%! private long computeFactorial(int n) { if (n == 0) return
1; else return n * computeFactorial(n - 1); } %>
B. <!-- HTML Comment -->
C. <% for (int i = 0; i <= 10; i++) { %>
D. <%= Math.pow(2, 3) %>
E. <%= i %>
19 The ________ directive lets you provide information for the
page, such as importing classes and setting up content
type. The page directive can appear anywhere in the JSP
file.
A.
B.
C.
D.
page
import
tablib
include
20 A class is a JavaBeans component if ____________________.
A. it is a public class
B. it has a public constructor with no arguments
C. it is serializable.
21 _______________ is a JSP expression.
A.
B.
C.
D.
<%= Math.pow(2, 3) %>
<%= new Date().toString() %>
<%= i %>
<% for (int i = 0; i <= 10; i++) { %>
22 Which of the following is a JSP implicit object?
A.
B.
C.
D.
E.
response
application
out
session
request
23 _______________ is a JSP scriptlet.
A. <!-- HTML Comment --%>
B. <%= i %>
C. <%! private long computeFactorial(int n) { if (n == 0)return
1;else return n * computeFactorial(n - 1); } %>
D. <% for (int i = 0; i <= 10; i++) { %>
E. <%= Math.pow(2, 3) %>
24 The JSP explicit object out is actually _________.
4
A.
B.
C.
D.
E.
A.
B.
C.
D.
E.
response.getWriter()
response.getOutputStream()
request.getOutputStream()
application
request.getWriter()
25 _______________ is a JSP comment.
<%-- i --%>
<!-- HTML Comment -->
<%= i %>
<% for (int i = 0; i <= 10; i++) { %>
<%! private long computeFactorial(int n) { if (n == 0) return
1; else return n * computeFactorial(n - 1); } %>
26 Assume that the file named policy contains the permission
for registering a remote object with an RMI registry. To
run the program (e.g., RegisterWithRMIServer) that
registers a remote object with an RMI registry, use the
command _________ from the command window.
A.
B.
C.
D.
java RegisterWithRMIServer
java –Djava.security.policy=policy RegisterWithRMIServer
java –Dpolicy=policy RegisterWithRMIServer
java RegisterWithRMIServer java –Djava.security.policy=policy
27 To start an RMI registry, use ____________ from the command
window.
A.
B.
C.
D.
rmiregistry
start rmiregistry
rmiregistry 7000
start rmiregistry 7000
28 ___________ is an object that resides on the client host
and serves as a surrogate for the remote server object.
A.
B.
C.
D.
E.
Server object interface
Server implementation
RMI Registry
Server Skeleton
Server stub
29 ____________is a class that implements the remote object
interface.
A.
B.
C.
D.
Server
Server
Server
Server
object interface
Skeleton
stub
implementation
5
E. RMI Registry
30 To register a remote object o with a name t at port 7000 on
host panda.armstrong.edu, use
A.
B.
C.
D.
Naming.rebind("rmi://panda.armstrong.edu:7000/t", o);
Name.bind("rmi://panda.armstrong.edu:7000/t", o);
Naming.bind("rmi://panda.armstrong.edu:7000/t", o);
Name.rebind("rmi://panda.armstrong.edu:7000/t", o);
31 ___________ is an object that resides on the server host,
communicates with the stub and the actual server object.
A.
B.
C.
D.
E.
Server object interface
RMI Registry
Server stub
Server Skeleton
Server implementation
32 ____________is a utility that registers remote objects and
provides naming services for locating objects.
A.
B.
C.
D.
E.
Server stub
Server object interface
Server Skeleton
Server implementation
RMI Registry
33 Each remote object has a unique name identified by an URL
with the protocol rmi as follows:
A.
B.
C.
D.
http://host:port/name
//host:port/name
http://host/name
rmi://host:port/name
34 __________ provides the naming services for the server to
register the object and for the client to locate the
object.
A.
B.
C.
D.
E.
Server stub
RMI Registry
Server implementation
Server Skeleton
Server object interface
35 Which of the following statements are true when passing
arguments in a remoter method call.
A. Primitive data types, such as char, int, double, or boolean,
are passed by value like a local call.
B. Remote object types are passed differently from local objects.
When a client invokes a remote method with a parameter of a
6
remote object type, the stub of the remote object is
passed. The server receives the stub and manipulates the
parameter through it.
C. Local object types, such as java.lang.String, are also passed
by value, but this is completely different from passing an
object parameter in a local call. Any object can be used as
a parameter in a remote call as long as it is serializable.
The stub serializes the object parameter and sends it in a
stream across the network. The skeleton deserializes the
stream into an object.
D. When a client invokes a remote method with parameters, passing
the parameters is handled by the stub and the skeleton.
36
RMI is about _______________.
A. accessing remote objects and invoking methods from remote
objects.
B. java.lang.Cloneable
C. passing objects between a server and a client
D. passing primitive data between a server and a client
37 Which of the following statements are true?
A. RMI enables you to program at a higher level of abstraction.
It hides the details of socket server, socket, connection,
and sending or receiving data. It even implements a
multithreading server under the hood, whereas with socketlevel programming you have to explicitly implement threads
for handling multiple clients.
B. In socket-level programming, a client operation to send data
requires a server operation to read it. The implementation
of client and server at the socket-level is tightly
synchronized.
C. RMI clients can directly invoke the server method, whereas
socket-level programming is limited to passing values.
D. RMI applications are scalable and easy to maintain. You can
change the RMI server or move it to another machine without
modifying the client program except for resetting the URL
to locate the server.
38 A remote object must be an instance of ______________.
A.
B.
C.
D.
java.rmi.Remote
java.rmi.RemoteObject
java.io.Serializable
java.lang.Cloneable
39 To locate a remote object with a name t at port 7000 on
host panda.armstrong.edu, use
7
A. Remote remoteObj =
Name.lookup("rmi://panda.armstrong.edu:7000/t");
B. Remote remoteObj =
Name.lookup("//panda.armstrong.edu:7000/t");
C. Remote remoteObj =
Name.lookup("http://panda.armstrong.edu:7000/t");
D. Remote remoteObj =
Naming.lookup("rmi://panda.armstrong.edu:7000/t");
40 ____________ is a subinterface of java.rmi.Remote that
defines the methods for the server object.
A.
B.
C.
D.
E.
Server stub
Server implementation
Server object interface
RMI Registry
Server Skeleton
Keys:
1. B
2. B
3. D
4. B
5. ABC
6. C
7. D
8. B
9. C
10. D
11. B
12. D
13. D
14. C
15. A
16. D
17. BC
18. A
19. A
20. ABC
21. ABC
22. ABCDE
23. D
24. A
25. A
26. B
27. BD
28. E
8
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
D
AC
D
E
B
B
ABCD
A
ABCD
A
D
C
9
Download