java软件工程师笔试题目(I) 规则: 1. 时间:40分钟 2. 个人独立完成,不能使用手机等上网上查询。如果被发现作弊,则零分。 3. 为了环保和节约纸张,请在答题卡上填写答案 一、不定项选择题(每题5分) Question 1 Given: 11. public class Test { ( e6 r6 T6 B4 e0 ]# t l/ ^7 [
12. public static void main(String [] args) {
/ L* P5 r% h: N* I13. int x =5; 0 P' c& P/ T Y9 H
14. boolean b1 = true;
' I5 ?* \0 B8 }+ B; c15. boolean b2 = false; 7 b: @# n7 ?! L* T: Q
17.if((x==4) && !b2) , W, z( s7 }4 z- A4 Z0 P6 g
18. System.out.print(”l “); / y/ W3 o# @% k; j+ A; e
19. System.out.print(”2 “);
! {7 q8 t4 h) a7 n' t- Z20. if ((b2 = true) && b1) & ]8 k+ Q9 l* O, n& W
21. System.out.print(”3 “); 4 Z/ o. r( g. ?3 S
22. } 2 p/ C2 v, I& w; }3 L
23. }
+ `, R' a8 g& ~3 H3 Y5 {What is the result?
' _' l9 \* f5 ~& _" MA. 2 & E, T- R9 z; Q' ?/ f: \; G) S
B. 3 a' q" T9 \& ?
C. 1 2
" ^' f$ c1 e8 z7 e4 ~D. 2 3 ) h! z/ V7 s: A1 ]0 R9 r/ B
E. 1 2 3 4 n& j8 t( w; e' W$ }
F. Compilation fails. & q) z! Q. l" T5 V" c2 ]# g7 l
G. Au exceptional is thrown at runtime. Question 2 Assume that country is set for each class. Given: 10. public class Money { ; x, d; m" i. Q( [ j
11. private String country, name; 9 Z" W$ I" M9 X! p7 i I
12. Public String getCountry() { return country; } * J7 s5 F0 g% Y4 A
13.} and: 24. class Yen extends Money {
, Y, m( o" E6 D0 y& r0 M$ u L: H2 z25. public String getCountry() { return super.country; } " p) ^) E9 @4 ?& b; _3 a
26. }
- H+ J, z9 y( I27.
- r0 b, M% s0 C# \28. class Euro extends Money {
$ i& T. J% \$ \$ h. n* ? d29. public String getCountry(String timeZone) {
3 P, H3 w f: M8 o x* ~7 @+ f30. return super.getCountry(); 5 C" Z1 P+ E, W$ Y* U
31. }
: ~9 @4 g3 l7 c& W0 y32. } # Z1 [; q3 X( e7 l
Which two are correct? (Choose two.) A. Yen returns correct values. / Q. T( h, n0 Y5 u
B. Euro returns correct values. , O/ @! }, m3 T
C. An exception is thrown at runtime. 9 D! s( i! H0 e3 |
D. Yen and Euro both return correct values. , w- d8 Z: Z, A5 S, e- h
E. Compilation fails because of an error at line 25. Y' J1 Z# f7 n c3 N
F. Compilation fails because of an error at line 30. Question 3 Given: 10. package com.billionsfinance.test; 6 w. O: U. x3 a+ h! X
11. public class Geodetics {
& l) j9 x9 Y4 t12. public static final double DIAMETER = 12756.32; // kilometers ' b" k6 p0 i+ i7 n
13. } / j* s8 S: x8 E
Which two correctly access the DIAMETER member of the Geodetics class? (Choose two.) A. import com.billionsfinance.test.Geodetics;
8 \0 x) a8 | h2 T7 l5 R% Spublic class TerraCarta { 8 V" Q/ n6 c/ |+ s: K* [
public double halfway()
9 Z( q* \) \4 W; F- [# b2 J' @& s{ return Geodetics.DIAMETER/2.0; } } B. import static com.billionsfinance.test.Geodetics; 2 E3 ]0 O: r! t d6 w1 n/ N
public class TerraCarta {
! Z, ~# |; |) B4 R/ A3 hpublic double halfway() { return DIAMETER/2.0; } } C. import static com.billionsfinance.test.Geodetics. *; public class TerraCarta {
4 I' F, Q6 E# U, k4 v$ G5 Wpublic double halfway() { return DIAMETER/2.0; } } D. package com.billionsfinance.test; , s; v/ R2 k! Y
public class TerraCarta { * D7 Z5 E. ^( ~6 t$ X7 C8 ]
public double halfway() { return DIAMETER/2.0; } } Question 4 Given: 1. class TestA {
$ p6 J5 n/ g5 w2. public void start() { System.out.println(”TestA”); } : y4 k0 k# @+ F3 Z9 ?+ Z. Z8 U- n3 o, [
3. } # x7 u; a5 v9 h
4. public class TestB extends TestA { ; E8 J5 T9 j4 X8 Y% ~
5. public void start() { System.out.println(”TestB”); } 3 l" ]5 F) ~. ^+ k; q3 [! a' L
6. public static void main(String[] args) { $ F" p+ ~. E+ m& l' |5 B% ^
7. ((TestA)new TestB()).start();
$ M2 n2 k) i3 r; Q8. } 2 R+ K0 e3 P9 A) p
9. }
. s, i' s* n3 g- uWhat is the result? A. TestA
6 q' c$ ~* ?" \% lB. TestB ^4 V$ n' E+ J2 C, G3 z& F
C. Compilation fails. # y2 N6 r) L; F
D. An exception is thrown at runtime. Question 5 Given: 11. public static void main(String[] args) {
4 L; S% ]$ u7 g12. String str = “null’; # C3 I& m3 I$ {2 V8 b
13. if (str == null) {
, y$ B, w+ g6 @14. System.out.println(”null”); - J' {, h" \3 L N' F5 Z' y
15. } else (str.length() == 0) { + c2 _% R3 m2 ]) t
16. System.out.println(”zero”);
y2 r8 f r* m j17. } else { , k- @# g: s1 T" s3 u
18. System.out.println(”some”);
; ]0 k; Z2 |. w19. } * \* v& v* l' W( |3 l- f
20. } 3 s% D+ U0 N+ V6 K/ Z
‘What is the result? A. null 7 y1 H; J2 [; T- A2 N( M
B. zero
+ Z {$ y5 h: r% o0 u' l2 H" KC. some
# }6 N5 O& q4 L5 UD. Compilation fails. * b* C. L0 Q" Q3 L
E. An exception is thrown at runtime. Question 6 Given: 33. try { & ?6 r9 S( g, B% ~
34. // some code here 3 g; ?' B9 L2 Q) r
35. } catch (NullPointerException e1) { 5 `% G% a4 d! q5 q
36. System.out.print(”a”); * D+ m) R3 x. Y2 ?) A7 a3 {
37. } catch (RuntimeException e2) { / \) _- s ? H4 V& U4 @2 R
38. System.out.print(”b”); 2 `" P% V4 ?% i ]
39. } finally { . y$ r1 B0 K* C
40. System.out.print(”c”);
. X/ m0 g( l. W3 H0 M, N41. }
( F) _! p) R1 R2 eWhat is the result if a NullPointerException occurs on line 34? & G0 u/ `+ S$ }: Y- Q; Z2 Y( l
A. c
% {% L+ S/ t3 }" T# ?5 }% ~B. a
& G6 N- M) n5 s3 kC. ab ; r2 x" \: [3 q* h2 [- R/ ~) I( G
D. ac ( Z% P) H' W! g6 l
E. bc 3 l4 Q5 @4 k: y8 e* h
F. abc Question 7 Given: 1. public class TestString 1 { " p" h4 w; d9 p1 l3 @2 |/ v
2. public static void main(String[] args) {
$ d7 `$ ?- s/ a3. String str = “420”;
; X" \% N; r. c: @8 c4. str += 42;
# E Q6 P) B% @( S5. System.out.print(str); 1 x5 I) u4 V" X! A4 g; H; x* }! {
6. }
3 M; \$ h- P, @) r1 Y# a! x0 I7. }
. S9 E" _# k, a1 \7 e$ H4 @What is the output? A. 42 4 d: A4 \; g* y3 O2 |" r
B. 420
, E0 ^8 Y3 ^/ O1 j" w& uC. 462 ! v) t+ C& s, q- w- \$ R A% N
D. 42042 - J! j5 o8 S% s+ v# M2 K# e
E. Compilation fails.
+ M$ C0 V [) H- v- xF. An exception is thrown at runtime. Question 8 Given this method in a class: 21. public String toString() {
7 G6 v8 s$ y7 O$ N I22. StringBuffer buffer = new StringBuffer();
4 l& d0 O5 c" h {0 N- K. M" b" {# L D/ T23. buffer.append(’<’); ! b" ?3 D, ~2 h
24. buffer.append(this.name);
8 ~1 H+ D* @$ w/ F! e, t# D. K25. buffer.append(’>’); - |+ M1 O. g% y D
26. return buffer.toString();
7 Q9 h: q% k0 o) w27. } * H) x ?+ \3 U8 ?* B0 @
Which is true? A. This code is NOT thread-safe.
' w6 f- K+ B, @, b) YB. The programmer can replace StringBuffer with StringBuilder with no - S/ y& [8 `9 g4 n
other changes. / O; y6 _7 M) ?5 u3 R6 z. X& a
C. This code will perform well and converting the code to use 6 z! {, Q2 \4 x6 i+ }9 k
StringBuilder will not enhance the performance.
' T k7 U: B/ @1 s2 _& _9 Q4 ?D. This code will perform poorly. For better performance, the code
2 v; e/ T: D3 t' q j7 k: Ushould be rewritten: return “<“+ this.name + “>”; Question 9 哪个语句不会建立隐式事务? A.INSERT B.UPDATE C.DELETE D.SELECT FOR UPDATE E.以上语句都会建立隐式事务 Question 10 EMP表不是分区表和索引化表,执行以下语句,哪两个说法是正确的? ALTER TABLE emp DROP COLUMN first_name;
& J0 r) t h9 ~1 j' _9 v9 @; x1 Y+ r
/ g' F0 i0 o# |+ d* h" y
A. FIRST_NAME列将被删除,如果该列不包含数据; ! m+ Y! o9 t% v3 M
B. FIRST_NAME列将被删除,如果它不是表中仅有的列; C. 如果以上SQL语句加上SET UNUSED子句,FIRST_NAME列可以被回滚; D. 如果以上SQL语句加上CASCADE子句,FIRST_NAME列可以被删除,即使它是主码列。 Question 11 关于子查询以下哪两种说法是正确的? A. 外层查询返回结果之后,执行内层查询 B. 先执行子查询,再执行外层查询 C. 对于子查询返回的结果,外层查询只执行一次 D. 外层查询返回的每行结果都与内层查询结果进行比较 Question 12 你需要把NEW_CUST表中的新客户信息导入CUST和CUST_SPECIAL表,如果客户 信誉度大于10000,需要导入CUST_SPECIAL表,所有新客户信息都要导入CUST表,使用哪种技术可以尽快完成导入? A.外部表 B. MERGE 命令 C.INSERT多表插入命令 D.带有 WITH CHECK OPTION子句的INSERT命令 Question 13 分数表scores设计如下: courseID(课程编号) studentID(学生编号) score(分数) 另有一个学生信息表student,包含studentID,sname(学生姓名)。 已知并非所有学生都参加了courseID为0001的考试,现在查询所有参加0001号课程考试及格学生的学生姓名,下面正确的是()。A A. select sname from student where studentID in (select studentID from scores where courseID = 0001 and score>=60) B. select sname from student where studentID = (select studentID from scores where courseID = 0001 and score>=60) C. select sname from student where studentID not in (select studentID from scores where courseID = 0001 and score<=60) D. select sname from student where studentID exists (select studentID from scores where courseID = 0001 and score>=60) Question 14 要依赖于抽象,不要依赖于具体。即针对接口编程,不要针对实现编程,是( )的表述 A.开-闭原则 B.接口隔离原则 C.里氏代换原则 D.依赖倒转原则 Question 15 “不要和陌生人说话” 是( )原则的通俗表述 A.接口隔离 B.里氏代换 C.依赖倒转 D.迪米特:一个对象应对其他对象尽可能少的了解 Question 16 对象适配器模式是( )原则的典型应用。 A.合成聚合复用原则 B.里式代换原则 C.依赖倒转原则 D.迪米特法则 二、简答题(每题5分) 1、AOP和IOC的概念以及在spring中是如何应用的。 2、简单描述hibernate持久化对象三种状态转换关系。 3、spring的事务有几种方式?并描述spring事务的隔离级别和传播行为。 4、简要阐述struts2的执行流程。 三、设计题 某时装邮购提供商拟开发订单处理系统,用于处理客户通过电话、传真、邮件或Web 站点所下订单。其主要功能如下: (1)增加客户记录。将新客户信息添加到客户文件,并分配一个客户号以备后续使用。 (2)查询商品信息。接收客户提交商品信息请求,从商品文件中查询商品的价格和可订购数量等商品信息,返回给客户。 (3)增加订单记录。根据客户的订购请求及该客户记录的相关信息,产生订单并添加到订单文件中。 (4)产生配货单。根据订单记录产生配货单,并将配货单发送给仓库进行备货;备好货后,发送备货就绪通知。如果现货不足,则需向供应商订货。 (5)准备发货单。从订单文件中获取订单记录,从客户文件中获取客户记录,并产生发货单。 (6)发货。当收到仓库发送的备货就绪通知后,根据发货单给客户发货;产生装运单并发送给客户。 (7)创建客户账单。根据订单文件中的订单记录和客户文件中的客户记录,产生并发送客户账单,同时更新商品文件中的商品数量和订单文件中的订单状态。 (8)产生应收账户。根据客户记录和订单文件中的订单信息,产生并发送给财务部门应收账户报表。 现采用结构化方法对订单处理系统进行分析与设计,完成以下两问题: 【问题 1】画出业务数据流程图 【问题 2】分析数据模型,画出相关ER图
/ R7 R7 D7 V: E, \ |