Exam2 (JSP, Servlet, JDBC)

该博客围绕JSP、Servlet、JDBC和JavaBeans等技术展开,包含30道选择题及答案。内容涉及存储过程调用、JDBC驱动加载、数据库元数据获取、JSP生命周期、Servlet并发处理等信息技术领域的关键知识。

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

内容概要:本文提出了一种基于融合鱼鹰算法和柯西变异的改进麻雀优化算法(OCSSA),用于优化变分模态分解(VMD)的参数,进而结合卷积神经网络(CNN)与双向长短期记忆网络(BiLSTM)构建OCSSA-VMD-CNN-BILSTM模型,实现对轴承故障的高【轴承故障诊断】基于融合鱼鹰和柯西变异的麻雀优化算法OCSSA-VMD-CNN-BILSTM轴承诊断研究【西储大学数据】(Matlab代码实现)精度诊断。研究采用西储大学公开的轴承故障数据集进行实验验证,通过优化VMD的模态数和惩罚因子,有效提升了信号分解的准确性与稳定性,随后利用CNN提取故障特征,BiLSTM捕捉时间序列的深层依赖关系,最终实现故障类型的智能识别。该方法在提升故障诊断精度与鲁棒性方面表现出优越性能。; 适合人群:具备一定信号处理、机器学习基础,从事机械故障诊断、智能运维、工业大数据分析等相关领域的研究生、科研人员及工程技术人员。; 使用场景及目标:①解决传统VMD参数依赖人工经验选取的问题,实现参数自适应优化;②提升复杂工况下滚动轴承早期故障的识别准确率;③为智能制造与预测性维护提供可靠的技术支持。; 阅读建议:建议读者结合Matlab代码实现过程,深入理解OCSSA优化机制、VMD信号分解流程以及CNN-BiLSTM网络架构的设计逻辑,重点关注参数优化与故障分类的联动关系,并可通过更换数据集进一步验证模型泛化能力。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值