java软件工程师笔试题目(I) 规则: 1. 时间:40分钟 2. 个人独立完成,不能使用手机等上网上查询。如果被发现作弊,则零分。 3. 为了环保和节约纸张,请在答题卡上填写答案 一、不定项选择题(每题5分) Question 1 Given: 11. public class Test {
8 j5 T! S9 s* q8 b/ _; j9 d' g5 o12. public static void main(String [] args) {
7 F/ y7 r6 I9 q Y13. int x =5;
- r1 G* P) O7 ^/ I& j( f& }' l14. boolean b1 = true; 1 t' U3 m# C) v' ?
15. boolean b2 = false;
) G# }. X. i. y2 L4 m' p# |) L2 W17.if((x==4) && !b2) 4 B! T; M' U# j3 ~! }) i9 C
18. System.out.print(”l “);
) {( }+ e+ a& s. [0 `19. System.out.print(”2 “); : _$ d2 F+ V- G' O; h
20. if ((b2 = true) && b1) 1 g4 ~. G: ~$ d" G
21. System.out.print(”3 “); 1 u+ W8 V: j' [& M' z# f
22. }
1 ^& d# r4 ~8 P23. }
/ ^: X: e! m3 e% P _. D: D7 u0 iWhat is the result? 6 Q8 k2 Y2 N! ?) s. o4 z2 M# E% }
A. 2 2 ]/ O5 d! g I1 j- f( F e
B. 3
8 k- _8 b) m! `0 M$ gC. 1 2
- |3 Z* n4 W4 ~, z0 o+ t! SD. 2 3
' v4 w7 k9 V4 ? u" J" zE. 1 2 3
7 B; _1 f6 k9 n) d+ F- cF. Compilation fails. " _7 s% W3 C* N! d
G. Au exceptional is thrown at runtime. Question 2 Assume that country is set for each class. Given: 10. public class Money {
& _# T% k/ |: g& p' U- c- F+ s11. private String country, name; . X3 P4 j+ P7 Y) v& b. e0 Z
12. Public String getCountry() { return country; } ! Y# C2 H6 N* o" N& L
13.} and: 24. class Yen extends Money {
; h% y. @/ q% U- ~/ m8 q, ^( u25. public String getCountry() { return super.country; } * K. ^$ d& A0 W2 l, r# J
26. } . Y m" E# C! E% m) @" r7 a% a. m
27. . R, U# M& ]5 m# b2 q
28. class Euro extends Money {
# L$ V- |! z! v, i29. public String getCountry(String timeZone) { H0 P6 ~9 u# T' A. x
30. return super.getCountry();
4 [* a8 U3 O% p+ P( V31. } 0 H" \# F9 G) C# {! P$ s* e! U
32. } * O9 b2 U# p! A- ]" K9 }4 ? W. m) u
Which two are correct? (Choose two.) A. Yen returns correct values.
- r" k! ~0 g( o! D [1 F" S3 jB. Euro returns correct values. 9 N. V2 C5 G2 a- m5 c& k' \
C. An exception is thrown at runtime.
6 X. R- o! @( q$ XD. Yen and Euro both return correct values.
* w: w7 ]7 l6 wE. Compilation fails because of an error at line 25.
' n* l6 {! u: i+ K9 G) qF. Compilation fails because of an error at line 30. Question 3 Given: 10. package com.billionsfinance.test;
2 Z; B$ e3 A7 a) z, g$ a' n11. public class Geodetics {
0 A4 }) R( N, y12. public static final double DIAMETER = 12756.32; // kilometers
+ L( d, U4 y+ j1 D9 ~13. }
7 w! d9 G: O/ e$ |Which two correctly access the DIAMETER member of the Geodetics class? (Choose two.) A. import com.billionsfinance.test.Geodetics;
# ~% A0 W4 O5 U; }! opublic class TerraCarta {
# A3 ?: `6 V1 x+ X7 i" apublic double halfway() ' B* ^7 B2 B. C1 ]
{ return Geodetics.DIAMETER/2.0; } } B. import static com.billionsfinance.test.Geodetics; : ~0 u: V6 u, e7 Q
public class TerraCarta {
" t7 e9 r8 u' l: o( Y. zpublic double halfway() { return DIAMETER/2.0; } } C. import static com.billionsfinance.test.Geodetics. *; public class TerraCarta {
; B, D" Q; Y3 ~ K6 Q7 c4 Npublic double halfway() { return DIAMETER/2.0; } } D. package com.billionsfinance.test;
+ ?+ ]2 n- t; D4 f' q* h% xpublic class TerraCarta { 0 t7 ^& }5 L3 c$ g; r+ m U: B
public double halfway() { return DIAMETER/2.0; } } Question 4 Given: 1. class TestA {
8 f3 ^7 Y D4 }6 \2. public void start() { System.out.println(”TestA”); }
8 y+ m4 }, ?; S4 Q$ U3 P3. }
1 W {# n: ^5 P% l2 E! ^7 u4. public class TestB extends TestA {
; _- c+ M8 A4 `" y% Q3 L5. public void start() { System.out.println(”TestB”); }
4 {9 j' L+ i7 \! ]) f6. public static void main(String[] args) {
) g! a5 d3 R5 h$ d9 i0 W2 }7. ((TestA)new TestB()).start();
- n, G5 \" v- h Q3 G8. }
4 X( G: B9 m) A {8 U4 S9. } ( p' E* {) O4 ?
What is the result? A. TestA 9 P v/ @/ i: H' l$ J7 {4 o- r
B. TestB
1 D3 E$ Q0 e6 J P, MC. Compilation fails. / x* Z" m2 D0 t6 H0 a0 H
D. An exception is thrown at runtime. Question 5 Given: 11. public static void main(String[] args) {
: @. W0 a# M* { T/ L9 B12. String str = “null’;
( H/ M- q, q) Y' ?- q4 }13. if (str == null) {
* Q4 ]/ ] j+ v) h5 D/ o14. System.out.println(”null”); ' b5 N8 b. Q- y+ }' ?& j
15. } else (str.length() == 0) { ; @% Y, z0 N3 \/ b/ h; k' I* g
16. System.out.println(”zero”); 5 L* P0 f' p" f0 S8 P4 O8 q o
17. } else {
8 i: l* R: G4 y8 |5 W18. System.out.println(”some”);
* {7 d: ~ W, f0 j4 i19. }
v# u' j) L& K, _5 h+ r20. }
8 _+ C8 v- ?, G6 T" I6 ~9 x& D‘What is the result? A. null
3 v* p* V, l+ y! PB. zero 8 ]' ^. {% L3 |$ J9 Y2 D
C. some 0 k- h2 P" k8 L4 x2 K4 B
D. Compilation fails.
& v6 E2 o9 `4 E, I/ J( E& GE. An exception is thrown at runtime. Question 6 Given: 33. try {
/ b. s% V, a# S% x, k$ V. b8 \34. // some code here : N5 I- y$ J8 V6 Y1 ?8 V* |5 V
35. } catch (NullPointerException e1) {
G" E& W4 x$ E1 U1 {36. System.out.print(”a”); 9 I0 Q C9 W- C& A: a; p8 f$ f2 R2 l
37. } catch (RuntimeException e2) {
7 S3 M7 U. \; A" B, S! Q38. System.out.print(”b”); 3 J s* s1 X9 Q# ?8 {/ F
39. } finally {
! q t v4 T9 V& T9 i8 h" B40. System.out.print(”c”);
2 E. M1 D, e# e- h+ u* m41. } 6 [9 A& k# [2 ^8 N, E/ |( j% a2 |
What is the result if a NullPointerException occurs on line 34?
/ x- m5 D/ U& I0 G1 n- UA. c
, e% R: q4 J5 K3 L( C: B/ FB. a - l8 W: C- B& c p
C. ab 4 F4 l. f: H. v- @3 R
D. ac
7 T' J" B5 D; X/ m+ {4 Z0 YE. bc
$ ?! y# O2 |0 m/ i% LF. abc Question 7 Given: 1. public class TestString 1 { $ B! F; ]8 w% L3 l) j9 H7 f
2. public static void main(String[] args) { 0 P9 r/ o V$ I2 u2 |
3. String str = “420”; 8 ]0 }! L% L* V" T) A
4. str += 42; - C1 x4 Y3 f2 w k9 b3 o4 s
5. System.out.print(str); , X2 {7 }! P8 i* w
6. }
6 V3 O2 q$ @$ Z! Q. w6 o0 [* h7. }
2 c: e8 T6 d4 g/ e7 _& O! BWhat is the output? A. 42
/ e$ m; a' G' j% X6 s" rB. 420
- P4 [. ]6 c' jC. 462
* p2 _ O, o2 c: @- k" g" c) LD. 42042 6 ~* O9 b6 E" c! P0 T' b5 m& R4 F
E. Compilation fails. + k" j8 n8 J# r; _7 z6 I3 n: H
F. An exception is thrown at runtime. Question 8 Given this method in a class: 21. public String toString() {
$ E* s" r9 U5 ]5 U2 S8 D22. StringBuffer buffer = new StringBuffer();
% j, E2 w# y' u5 W: I- Z23. buffer.append(’<’); : b D: I) i5 S- n+ n5 H: W
24. buffer.append(this.name); : r3 |: ?- a4 h; u( R! ^5 }
25. buffer.append(’>’); - z" u- N% U- E" K6 i: J5 o
26. return buffer.toString();
' T" q a( d5 ?7 A* b27. }
: S- A5 W0 H( u% O; SWhich is true? A. This code is NOT thread-safe.
2 L/ j0 a( \8 r8 k, T$ WB. The programmer can replace StringBuffer with StringBuilder with no 5 N+ w6 ^; S2 T) Y
other changes. $ b. X- m& B9 q' M
C. This code will perform well and converting the code to use . {" s5 G) [6 l/ x, V# I( i
StringBuilder will not enhance the performance.
* O9 w2 y; [# v/ p" g3 X! dD. This code will perform poorly. For better performance, the code
! r0 I: B- u5 B% f9 m0 B4 gshould 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;
$ i/ C# W. c6 `
/ S$ [9 c5 H5 @, b- ^A. FIRST_NAME列将被删除,如果该列不包含数据; / `( m1 X& {* b" O# l2 F- W1 V
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图
/ ]6 C( ^( D" n5 V4 w0 B3 w |