Exam2 (JSP, Servlet, JDBC)

1. If you need to use a stored procedure with output parameters, which of the following statement type should be used to call the procedure?

  A. Statement

  B. PreparedStatement

  C. CallableStatement

The answer is:C

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

2. Which of the following will not cause a JDBC driver to be loaded and registered with the DriverManager?

  A. Class.forName(driverString);

  B. new DriverClass();

  C. Include driver name in jdbc.drivers system property

  D. None of the above

The answer is:D

 

3. From which object do you ask for DatabaseMetaData?

  A. Connection

  B. ResultSet

  C. DriverManager

  D. Driver

The answer is:A

 

4. A customer with a computer can only has a session?

  A. True

  B. False

The answer is:B

 

5. If one intends to work with a ResultSet, which of these PreparedStatement methods will not work?

  A. execute()

  B. executeQuery()

  C. executeUpdate()

The answer is:C

 

6. Can a servlet instance serves more than one requests at the same time?

  A. Yes

  B. No

The answer is:A

 

7. How can I use JDBC to create a database?

  A. Include create=true at end of JDBC URL

  B. Execute "CREATE DATABASE jGuru" SQL statement

  C. Execute "STRSQL" and "CREATE COLLECTION jGuru" SQL statements

  D. Database creation is DBMS specific

The answer is:D

 

8. Which character is used to represent an input parameter in a CallableStatement?

  A. %

  B. *

  C. ?

  D. #

The answer is:C

 

9. Which one of the following will not get the data from the first column of ResultSet rs, returned from executing the following SQL statement: SELECT name, rank, serialNo FROM employee.

  A. rs.getString(0);

  B. rs.getString("name");

  C. rs.getString(1);

The answer is:C

 

10. Which of the following can you do with a JDBC 2.0 database driver that you cannot with a JDBC 1.x driver?

  A. Batch multiple statements, to be sent to the database together

  B. Scroll through result sets bi-directionally

  C. Work with SQL3 data types directly

  D. All of the above

The answer is:A

 

11. Which class contains the transaction control methods setAutoCommit, commit, and rollback?

  A. Connection

  B. Statement

  C. ResultSet

The answer is:C

 

12. When a JSP page is compiled, what is it turned into?

 A.  Applet

 B.  Servlet

 C.  Application

 D.  Mailet

The answer is:B

 

13. Which of the following is not a standard method called as part of the JSP life cycle?

A.  jspInit() 

 B.  jspService()

 C.  _jspService()

 D.  jspDestroy()

The answer is:C

 

14. If you want to override a JSP file's initialization method, within what type of tags must you declare the method?

A.  <@ @>

 B.  <%@ %>

 C.  <% %>

 D.  <%! %>

The answer is:D

 

15. Which of the following can not be used as the scope when using a JavaBean with JSP?

 A.  application 

 B.  session

 C.  request

 D.  response

 E.  page

The answer is:A

 

16. The implicit JSP objects like request, response, and out are only visible in the _jspService() method.

 A.  True 

 B.  False 

The answer is:B

 

17. What is the key difference between using a <jsp:forward> and HttpServletResponse.sendRedirect()?

 A.  forward executes on the client while sendRedirect() executes on the server.

 B.  forward executes on the server while sendRedirect() executes on the client.

 C.  The two methods perform identically.

The answer is:C

 

18. Which of the following statements makes your compiled JSP page implement the SingleThreadModel interface?

 A.  <%@ page isThreadSafe="false" %> 

 B.  <%@ page isThreadSafe="true" %> 

The answer is:B

 

19. Of the following four valid comment styles that can be used within JSP pages, which can the end user see?

 A.  <%--  My comments  <% out.println("Hello World"); %>--%>

 B.  <!-- (c)2000 jGuru.com -->

  C. <% // For <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />Loop  

for (int i=1; i<=4; i++) {%>  

<H<%=i%>>Hello</H<%=i%>>

<% } %>

 D. <% /** yet another comment */

  JavaDoc Rules

%>

The answer is:A

 

20. How can a servlet call a JSP error page?

 A.  This capability is not supported.

 B.  When the servlet throws the exception, it will automatically be caught by the calling JSP page.

 C.  The servlet needs to forward the request to the specific error page URL. The exception is passed along as an attribute named "javax.servlet.jsp.jspException".

 D.  The servlet needs to redirect the response to the specific error page, saving the exception off in a cookie.

The answer is:C

 

21. When using a JavaBean to get all the parameters from a form, what must the property be set to (??? in the following code) for automatic initialization?

 

<jsp:useBean id="fBean" class="govi.FormBean" scope="request"/>

<jsp:setProperty name="fBean" property="???" />

<jsp:forward page="/servlet/JSP2Servlet" />

 

 A.  * 

 B.  all

 C.  @

D.       =

The answer is:B

 

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

The answer is:D

 

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

The answer is:B

 

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

The answer is:D

 

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

The answer is:B

 

26. What type of scriptlet code is better-suited to being moved 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.

The answer is:C

 

27. How to retrieve a value from a request object which we inputted in HTML form?

  A. req.getAttribute()

  B. req.getParameter()

The answer is:A

 

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

The answer is:D

 

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

The answer is:C

 

30. 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 JSP pages output, returning control to the calling resource.

The answer is:D

阅读更多
换一批

没有更多推荐了,返回首页