java软件工程师笔试题目(I) 规则: 1. 时间:40分钟 2. 个人独立完成,不能使用手机等上网上查询。如果被发现作弊,则零分。 3. 为了环保和节约纸张,请在答题卡上填写答案 一、不定项选择题(每题5分) Question 1 Given: 11. public class Test { 9 z4 z0 k. w* W' g9 n
12. public static void main(String [] args) {
) R1 Z2 w6 W2 p2 G7 l13. int x =5;
( v, E# z u% ^9 V6 A) H14. boolean b1 = true; ! p7 r. c+ d! ^+ K& `5 D0 v+ M
15. boolean b2 = false;
& v2 m' ~, W/ I( k' ~17.if((x==4) && !b2) 4 \' Z* A3 j& C5 M; e8 x/ c7 r
18. System.out.print(”l “); " b4 `! F2 P/ l: w1 ^1 m9 C: x, S; `
19. System.out.print(”2 “);
- U* g- O3 R% M' [1 z1 R20. if ((b2 = true) && b1) 7 i/ R. j( R5 V" D
21. System.out.print(”3 “); ! T- l& f" D e: i
22. }
& N2 R" [, r: B23. } * ~) x' E! e: \3 ]/ p
What is the result? - v$ t' d1 F, c% e
A. 2
, p! u4 L+ t: j' jB. 3 $ z/ U) X. {2 H# o5 p& u# t8 Q( ]0 E
C. 1 2 : P' D3 s) @8 `
D. 2 3
0 S; G& ~" {5 V) A( R+ F) q/ F- |! P( vE. 1 2 3
$ T) J! {0 ?2 x$ T0 O8 x5 t' pF. Compilation fails.
4 N2 X# H( r7 RG. Au exceptional is thrown at runtime. Question 2 Assume that country is set for each class. Given: 10. public class Money { % u# C4 t. y: X. b6 i3 b( A- @
11. private String country, name;
! V+ m2 B$ F3 V- I- d12. Public String getCountry() { return country; } 9 D7 [; t( p+ I# S
13.} and: 24. class Yen extends Money {
# G4 g$ @6 h* y9 q6 v0 p25. public String getCountry() { return super.country; } 0 b: i1 @# j3 g
26. } / |: Z8 q+ s3 Z
27.
, m* D9 q( [& u/ k9 _, J2 m* L3 ^! x( i! m28. class Euro extends Money {
7 h5 p1 _$ a6 S( A3 p+ M29. public String getCountry(String timeZone) { ' @. G' k/ w1 A
30. return super.getCountry();
) b* w( c; A# V31. }
! o$ m% g7 x: m7 _+ z" P( B32. } & L2 H- \) v/ e) c7 j
Which two are correct? (Choose two.) A. Yen returns correct values. - G' v" C2 X4 i/ h
B. Euro returns correct values. / i! ]8 Z. M, m3 H0 [! b" _; U
C. An exception is thrown at runtime.
6 s; v1 Z) @* Q4 b* tD. Yen and Euro both return correct values.
) M4 p% o9 M" d, ]4 y1 b" Q* QE. Compilation fails because of an error at line 25. ' l! M) \4 u! Z* b2 ]& z
F. Compilation fails because of an error at line 30. Question 3 Given: 10. package com.billionsfinance.test; + h: \- w* Q& w0 ]5 Y0 S7 f) h
11. public class Geodetics { % [2 ~; _6 D Y5 m' v/ l
12. public static final double DIAMETER = 12756.32; // kilometers 5 @3 u. @; ]0 h8 N, G* \
13. }
5 K0 I# X$ y7 _3 d o7 OWhich two correctly access the DIAMETER member of the Geodetics class? (Choose two.) A. import com.billionsfinance.test.Geodetics;
. M J4 w, m% ?2 \- j% [6 J, A& opublic class TerraCarta {
2 V! Y0 |/ ?. U0 f* F0 kpublic double halfway() 6 Z" G5 L/ O4 q1 @4 ^% q
{ return Geodetics.DIAMETER/2.0; } } B. import static com.billionsfinance.test.Geodetics;
7 `* a, E. e N. Cpublic class TerraCarta {
1 |# y% V% K; s% U) o# u" l, Fpublic double halfway() { return DIAMETER/2.0; } } C. import static com.billionsfinance.test.Geodetics. *; public class TerraCarta { ) f7 e% Z4 C+ k4 \, E0 L: i
public double halfway() { return DIAMETER/2.0; } } D. package com.billionsfinance.test;
5 \2 o: C5 @) }$ P# ppublic class TerraCarta { 0 n- p; c( p6 v: a
public double halfway() { return DIAMETER/2.0; } } Question 4 Given: 1. class TestA { : g- b) @& I+ }5 W: q( d
2. public void start() { System.out.println(”TestA”); } 2 h3 g4 Z. m1 p: ?6 d
3. } . N, O( y6 Q$ C& r
4. public class TestB extends TestA { 9 H: [- {& `3 p. S' }
5. public void start() { System.out.println(”TestB”); } % i& N2 F. `9 g
6. public static void main(String[] args) {
: C# H7 I0 y1 \* q; |9 V! S M4 {7. ((TestA)new TestB()).start();
* {2 e( \/ b6 u# I/ W8. } + s9 j% @* R% E+ s$ j7 r7 ?
9. }
# S9 V$ {! J8 L1 }What is the result? A. TestA
/ v7 U& r$ d( k9 f P# `2 [0 u1 zB. TestB * S8 r9 d' e+ ]! G$ i$ G6 E
C. Compilation fails.
0 y2 J7 Y* [- F: N1 q6 UD. An exception is thrown at runtime. Question 5 Given: 11. public static void main(String[] args) {
2 P) D/ ?$ ?. e# C, O12. String str = “null’; n* g& A3 C. u3 m6 b. M9 A6 |6 N! |
13. if (str == null) { ^: t+ F' M; K) w1 L1 E5 ?. \
14. System.out.println(”null”);
5 S! X9 T5 E @; i$ f15. } else (str.length() == 0) {
b1 b) m, o' b- C! R- a; @+ O7 O16. System.out.println(”zero”);
0 S4 q2 v' Q9 ^" q) ?' t- J17. } else {
' `6 i8 T7 R8 p& _18. System.out.println(”some”);
4 y5 O' ], [1 T2 @19. } * Q) B( H; N/ O1 F3 }" i' E3 l, K
20. } ! }, K- t+ m x h3 T! M/ T2 V; e7 f
‘What is the result? A. null
2 R) a+ p5 f/ E/ O. [4 ZB. zero # t* P _; }( A2 K; I ^
C. some
' Q7 T) F/ V, uD. Compilation fails. ( s1 s5 w P2 s% G. [/ Y! w
E. An exception is thrown at runtime. Question 6 Given: 33. try { + x q9 ^/ X }8 T
34. // some code here ' ?" w) |' q3 `( J; z$ N
35. } catch (NullPointerException e1) {
: x8 B9 z4 o' ^8 c' R36. System.out.print(”a”);
5 a0 C' [8 `2 Z- Q8 F2 a* ^& ~# W37. } catch (RuntimeException e2) {
: @: T2 D! C" o38. System.out.print(”b”); ) y- r7 f$ D X4 p
39. } finally {
/ N) N8 \% s J$ z/ \% E' W40. System.out.print(”c”);
6 j% }6 U( F1 q; Z7 W5 p7 B/ d: @41. } 1 j! m6 }; E2 n8 A2 \" F
What is the result if a NullPointerException occurs on line 34? 7 b& q* S" K* l8 T' [& V) q ]
A. c ( D/ q5 l6 c. T* s
B. a 5 Q+ H* ?& c0 F* @( r: j! @8 C
C. ab
; A% {$ a! i* HD. ac b% g) s7 j w
E. bc 4 }+ n# J+ X) |+ L, W: O
F. abc Question 7 Given: 1. public class TestString 1 {
" v/ s6 Y$ t5 {( g2. public static void main(String[] args) { 6 ~# F# ?- l( j9 g
3. String str = “420”; - U) K5 }+ f/ h1 F9 J
4. str += 42; ( h! ?, y* L# k: L7 R
5. System.out.print(str);
' v* w5 G; J7 t0 y: n! R$ R- ~3 q1 J' V0 z6. }
; V2 M3 e$ z6 y: E) D; Z7. } C% @) G; C( c
What is the output? A. 42
0 m. l! |% e2 D) x7 r% pB. 420
: A0 M- n; P' j- kC. 462 ( r0 G, i3 P" f9 D3 Z5 B3 u" P+ L) n: K
D. 42042
( a' K$ s$ E: u; Z; PE. Compilation fails. # Z3 R% [5 C% q; z
F. An exception is thrown at runtime. Question 8 Given this method in a class: 21. public String toString() {
/ H) O6 S5 w4 K' U5 a22. StringBuffer buffer = new StringBuffer();
8 Q- F( ?& o" @2 B. f23. buffer.append(’<’); 0 g ?/ l+ s, ~: G% ?6 A5 V
24. buffer.append(this.name); : s' ~0 q* S1 _: i& C
25. buffer.append(’>’);
" | F" ~! b, [! Y+ C- R26. return buffer.toString(); : L" f, A) a1 D
27. } 5 w2 r9 S/ x6 a1 j( D
Which is true? A. This code is NOT thread-safe. % D4 W; }1 y: m" q* }
B. The programmer can replace StringBuffer with StringBuilder with no
' T4 @! r8 B' p! a$ Vother changes.
$ U" r) q; D: W% ^C. This code will perform well and converting the code to use 7 A9 @4 c# e. m" h
StringBuilder will not enhance the performance. 3 G8 q( A; w# m2 [: `
D. This code will perform poorly. For better performance, the code
8 p9 a) p) i& O' Mshould 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;
1 N# R: P+ F& ], k* W
" |3 O; g* d% Z% N. Y
A. FIRST_NAME列将被删除,如果该列不包含数据; , r( l5 B+ b$ h1 V* P" T8 o4 Y3 `
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图
, X8 x3 N9 Y y C5 b2 ~/ m5 f |