Exam2 (JSP, Servlet, JDBC)

来源:互联网 发布:淘宝怎么不能买彩票了 编辑:程序博客网 时间:2024/04/29 08:17

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

 

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

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 运动鞋穿久了臭怎么办 体恤穿久了发臭怎么办 十七八岁青少年逆反心理怎么办 挨刚煮好的粥烫伤改怎么办? 5e的demo有水印怎么办 宝宝湿疹激素一停药复发怎么办 木工家装没事做怎么办 取票之后票丢了怎么办 补牙咬合低了点怎么办 留学生上美国网课上不了网怎么办 大四绩点不够2.0怎么办 ucas申请成绩下来后怎么办 在本校读研毕业东西怎么办 美国硕士gpa低于3.0怎么办 英国t4签证拒签怎么办 abc洗液过敏了怎么办 护士电子化注册忘记用户名怎么办 手机重力感应坏了怎么办 电脑所有驱动都删除了怎么办 毕业生没有签工作档案怎么办 澳洲两年工作签怎么办 上班一年没签劳动合同怎么办 公司拖欠工资怎么办没签劳动合同 brp丢了怎么办回国补 被怀疑假结婚该怎么办 中考作弊被捉了怎么办 露娜注册错了怎么办 去泰国开民宿怎么办工作签证 绩点2.7想出国怎么办 香港过境想去澳门怎么办 加拿大博士资格考试没通过怎么办 外国人没有学历怎么办工作签证 澳洲语言班挂了怎么办 英国学位翻译成文学硕士怎么办 没考上好的高中怎么办 毕业证12月发放申请英国怎么办 高二迷茫成绩差怎么办 高二期末考的差怎么办 法国留学签证办不下来怎么办 澳洲留学挂科签证续签怎么办 澳洲旅游签证被拒了怎么办