java软件工程师笔试题目(III) 规则: 1. 时间:40分钟 2. 个人独立完成,不能使用手机等上网上查询。如果被发现作弊,则零分。 3. 为了环保和节约纸张,请在答题卡上填写答案 一、不定项选择题(每题5分) Question 1 Given: 11. public class Test {
. Q5 r# b9 B4 y1 M5 t0 r12. public static void main(String [] args) {
! O/ {) e8 B: a13. int x =5;
% a R6 [# G+ |2 g8 w* y( I6 p14. boolean b1 = true; + u% Y3 K& O0 ~; b, ]
15. boolean b2 = false;
/ `* X ^8 W; g2 U$ ~( }2 [& D# l17.if((x==4) && !b2) / u* C+ J$ q' J# R9 @0 ?3 r- j7 z3 F
18. System.out.print(”l “); 9 M$ V8 e5 |* Q; ~5 i
19. System.out.print(”2 “);
" R+ b/ ^* W, q& Z; P- h6 o20. if ((b2 = true) && b1)
' n4 L4 T5 C: d4 q8 \21. System.out.print(”3 “); 7 n! c3 T8 D4 ]6 b8 a
22. } 7 K4 N" d) I. n" H |4 [0 q2 r4 b
23. }
0 y3 b: d0 d! ZWhat is the result?
; N+ x7 u3 U5 `8 |4 wA. 2
( U. q+ n+ ]. G( W" e. KB. 3 ( ?& |: A8 n" a5 O7 e' a
C. 1 2
7 z8 i' L* t* o0 {$ q" RD. 2 3 , L9 l3 ^; K- u* n# ]2 M
E. 1 2 3 3 R* S" v1 z2 Y. E, Q" @' k+ C v4 R
F. Compilation fails. % T. t' f5 P, y* f4 R Y
G. Au exceptional is thrown at runtime. Question 2 Assume that country is set for each class. Given: 10. public class Money {
5 @0 B5 l0 o! N( u$ t5 h7 x* }11. private String country, name; $ R9 H1 y6 h4 O1 x- w& ^
12. public String getCountry() { return country; } + H0 {& r* l- [ r, f0 f
13.} and: 24. class Yen extends Money { / A* n. b+ K+ Q+ a* n" K' i
25. public String getCountry() { return super.country; } & o5 p3 [9 |3 t9 m0 e
26. }
( o6 S5 |& y& B, i' [7 L4 b; F( I27.
% Q: k/ A1 ^0 N- H28. class Euro extends Money {
5 ]* n2 f N0 C0 Z+ K1 o29. public String getCountry(String timeZone) { . `* P% G$ i. Y+ r+ O
30. return super.getCountry();
& M. e5 y3 X% b0 w- ]' t31. } & }: ?0 O+ h. |; U. ?# W
32. }
7 B5 g( N& Y# q/ l, f o' QWhich two are correct? (Choose two.) A. Yen returns correct values. $ l5 i6 N! ~7 g1 P% ]% d
B. Euro returns correct values.
; o( ]1 B6 y+ F' d. }4 U _$ o" N# KC. An exception is thrown at runtime. - u- w5 M) M3 i0 b" ^6 U
D. Yen and Euro both return correct values. 8 y+ }2 q/ |" A A" q- [
E. Compilation fails because of an error at line 25.
+ I$ u" ]# ^9 q- \7 v' I' x" ZF. Compilation fails because of an error at line 30. Question 3 Given: 1. class TestA {
; B6 C. p& j5 ?( v' S7 q' d+ I2. public void start() { System.out.println(”TestA”); } 4 `; ^2 {! v& v2 @# }' @/ s: ?0 w
3. } 1 ~. A' T# X+ r0 N! \: |* O
4. public class TestB extends TestA {
8 {0 H$ d, K# Q0 \2 U& O5. public void start() { System.out.println(”TestB”); } " @+ P% n6 j4 Y6 s e
6. public static void main(String[] args) { ; N! ^2 ?; h; U3 F) H5 W3 z
7. ((TestA)new TestB()).start();
& E& D! l# S ?0 R1 _& k$ ]0 J5 z8. } " T. W0 @" y/ d5 l
9. } , p) [# V1 }, u+ M) M
What is the result? A. TestA 6 x: A. u# b, V$ T; y1 G B
B. TestB 8 o+ g/ v, n) F3 p( E8 g
C. Compilation fails.
& ^* X4 H% @- x: ]2 uD. An exception is thrown at runtime. Question 4 Given: 11. public static void main(String[] args) { & Z* `6 f& X, A
12. String str = “null’; $ D! A, B7 h! e" |0 T
13. if (str == null) { ! D+ E7 Q: [. ^# o2 [% l4 E
14. System.out.println(”null”);
% Z9 U0 A% n5 `: }/ k15. } else (str.length() == 0) { * @1 W0 u% s+ E) n2 H& w X
16. System.out.println(”zero”);
) M4 b- Z# K% G0 ]17. } else {
- q7 v3 w d. ]5 X9 s; ~18. System.out.println(”some”);
# u u# G# F5 O* \, P% R! o19. } ' f. i% p2 u8 q% R
20. }
) \6 j% S0 D% ?6 ]* C‘What is the result? A. null
& m. q% W7 B* l+ y* G& T6 U; YB. zero # T* i: {6 g1 w. T$ J* G
C. some
4 J) i0 a2 e+ o, ]* A" TD. Compilation fails. . \) n6 \9 U' d/ |) ]" a K3 p# M
E. An exception is thrown at runtime. Question 5 Given: 33. try { T4 I/ A, d6 |' u) k
34. // some code here
# G/ K+ \0 r% J% D7 R3 O& U1 E35. } catch (NullPointerException e1) {
1 H) k& v. ]; [/ ]+ B- d5 A36. System.out.print(”a”); & S- o6 t% G1 F4 G |
37. } catch (RuntimeException e2) { 6 k S. E2 V! p; E$ C
38. System.out.print(”b”); 7 m5 h; m9 ^; l$ N( `$ x0 c) i+ s
39. } finally {
3 P: E6 x P, d3 j; | o# q( _) H40. System.out.print(”c”);
7 Q4 G5 k0 M j: t/ x41. }
' Y3 }; Z' d. U& F2 Z% ]What is the result if a NullPointerException occurs on line 34? , T' w3 L5 |! T0 P, I; V7 u2 [! L
A. c
M& e+ A I0 |/ I" v& |- u) h9 F0 BB. a . f W4 w3 T$ M- }8 ?, N
C. ab 9 A4 d5 U, d( t& P
D. ac
) V. x0 k5 u( S" ^$ m3 uE. bc 6 V; u( O! L: i: I
F. abc Question 6 Given this method in a class: 21. public String toString() { # w8 ~8 g& u t+ c$ ^. v8 b0 G6 k
22. StringBuffer buffer = new StringBuffer();
8 O a O; y( H7 y23. buffer.append(’<’); , c; I& A' Y- b8 x5 D
24. buffer.append(this.name);
! H5 Y1 a' l/ u' r25. buffer.append(’>’);
; S( f( ~( H4 w! X/ ] r* ~, b26. return buffer.toString();
& L& K. [! v8 Z7 c: u V. c& ~27. }
2 d3 h' }5 R5 gWhich is true? A. This code is NOT thread-safe. # F/ [1 F0 L6 X8 v
B. The programmer can replace StringBuffer with StringBuilder with no ) d9 R6 `, e! k3 j% |# t7 w8 I
other changes. 2 O+ X" M" z$ W5 f
C. This code will perform well and converting the code to use
! c0 ] ?% i+ O) B, L1 fStringBuilder will not enhance the performance. % Z! F5 q9 H0 n3 R9 h
D. This code will perform poorly. For better performance, the code , T; d. o# Q! a! y5 f Q y4 [) j, P
should be rewritten: return “<“+ this.name + “>”; Question 7 Given: 11. String test= “a1b2c3”;
1 k: g; e; a% h. ]: C7 C: E12. String[] tokens = test.split(”\\d”);
( o' V' y" z8 G$ H: L13. for(String s: tokens) System.out.print(s +“ “);
$ G/ `$ \' u' B3 v' C. PWhat is the result? % L+ ~, ^. Q% v+ y3 p) h
A. a b c
% g' M6 S' n8 a; G* OB. 1 2 3 8 Z O4 e: X5 M1 n7 ?7 i% w* u# m% p
C. a1b2c3
; W" y8 u# R/ \; z) p1 T+ l5 A7 G$ xD. a1 b2 c3
# \. W8 i+ E$ P: J! [, ]E. Compilation fails. 8 i" e0 _1 q7 H1 v" g
F. The code runs with no output. * K* |6 c: o: K! \9 u# g
G. An exception is thrown at runtime. Question 8 Question 9 Question 10 请选择同向的图形: Question 11 Question 12 表USER_INFO的结构如下: 下面那些选项可以插入一行到该表中: A、INSERT INTO USER_INFO(USER_INFO_ID, USER_NAME, PASSWORD) VALUES(null,'BQ','password'); B、INSERT INTO USER_INFO VALUES('helloword_id','BQ','password'); C、INSERT INTO USER_INFO(USER_INFO_ID) VALUES('helloword_id'); D、INSERT INTO USER_INFO(USER_INFO_ID, USER_NAME, PASSWORD) VALUES('helloword_id','BQ','password'); Question 13 下面关于视图说法正确的是: A、一个视图可以作为只读被创建。 B、一个视图可以用来连接两个或者更多的表而创建。 C、一个视图在select语句中不能有一个order by 语句。 D、一个视图在select语句中不能同group by 语句一起创建。 E、一个视图必须在select语句中为列名定义别名。 Question 14 EMPLOYEES表数据如下: 选择下面正确的选项: A、SELECT * FROM EMPLOYEES WHERE SALARY>(SELECT MIN(SALARY) FROM EMPLOYEES GROUP BY DEPARTMENT); B、SELECT * FROM EMPLOYEES WHERE SALARY>(SELECT MIN(SALARY) FROM EMPLOYEES GROUP BY DEPARTMENT); C、SELECT * FROM EMPLOYEES WHERE SALARY>(SELECT MIN(SALARY) FROM EMPLOYEES); D、SELECT * FROM EMPLOYEES WHERE SALARY>ALL(SELECT SALARY FROM EMPLOYEES); Question 15 STUDENTS表为空表,添加主键STUDENT_ID列,那个选项能完成这个任务: A、ALTER TABLE STUDENTS ADD PRIMARY KEY STUDENT_ID; B、ALTER TABLE STUDENTS ADD CONSTRAINT PRIMARY KEY (STUDENT_ID); C、ALTER TABLE STUDENTS ADD CONSTRAINT STUD_ID_KEY PRIMARY KEY (STUDENT_ID); D、ALTER TABLE STUDENTS ADD CONSTRAINT STUD_ID_KEY PRIMARY KEY STUDENT_ID; Question 16 一个学生只能就读于一个班级,而一个班级可以同时容纳多个学生,学生与班级之间是()的关系。 A、一对一 B、一对多 C、 多对一 D、多对多
2 @; j3 i- K0 v |