java软件工程师笔试题目(II) 规则: 1. 时间:40分钟 2. 个人独立完成,不能使用手机等上网上查询。如果被发现作弊,则零分。 3. 为了环保和节约纸张,请在答题卡上填写答案 一、不定项选择题(每题5分) Question 1 Given: 11. public class Test { # {, O! E4 ]9 d/ Z$ u
12. public static void main(String [] args) {
+ F. R9 f3 A1 ~' n# _$ c- c9 ~2 C2 R13. int x =5;
* \7 Z+ i2 h9 ^2 R* h14. boolean b1 = true; * V8 R( K, S$ u( b5 T# ]
15. boolean b2 = false;
/ L. ^9 S8 W2 Q4 P$ |7 }' ?$ Y17.if((x==4) && !b2) * `4 I: R) c% c) p: H {
18. System.out.print(”l “);
# @7 ?) u" y. y1 h6 B19. System.out.print(”2 “);
5 w/ T, {$ {3 \20. if ((b2 = true) && b1) 3 C j1 s9 M& {+ X% U" c* t1 d
21. System.out.print(”3 “);
1 F5 n9 P, x g" {; X+ S$ E! ~: ?% W22. } - J2 x9 ^" i: H0 s( c
23. } , w3 ]4 \& |3 F
What is the result?
4 m+ L7 z( G; |. f$ Z* BA. 2 ' E/ f/ n# V3 A# v$ Y, t
B. 3 2 c0 t w4 S- E/ L( s/ H
C. 1 2 |' Z" ^$ }" ^9 o, ^. u _9 R
D. 2 3
9 I: ^" G: N! C0 @' n7 @1 q7 f: O$ t! aE. 1 2 3 2 b- H3 y2 ]& L. W6 @
F. Compilation fails. ) z5 Y( u% i6 G8 Y) l
G. Au exceptional is thrown at runtime. Question 2 Assume that country is set for each class. Given: 10. public class Money {
7 N# O/ |' |4 ~& }+ M11. private String country, name; - [5 R; S4 H8 Z. o
12. public String getCountry() { return country; }
, K/ o" R. h3 ]% Z! V4 |5 \13.} and: 24. class Yen extends Money { ) i, b3 f e/ l$ K3 [- u
25. public String getCountry() { return super.country; }
7 Y0 y o5 V. v& I26. }
& t6 w7 m, A8 X& S% |+ y D& k! P. K27. 6 L" h3 X2 _" V1 x' m0 a' g$ L
28. class Euro extends Money { % w5 R$ }8 ?, T' @. n
29. public String getCountry(String timeZone) {
3 L0 h; N% n7 U7 Y# A" M. Z2 g30. return super.getCountry(); / ]- N: r1 ~; D! i
31. }
0 P: T0 p6 \: c5 c) c- O. N32. }
! G `& m, R4 r# ?& C8 T' s1 |5 Y8 SWhich two are correct? (Choose two.) A. Yen returns correct values. - U5 Y& F* M* j& u0 L5 w
B. Euro returns correct values.
- Z3 O) z1 }7 a% AC. An exception is thrown at runtime.
% |4 t& h- V, s6 o1 H2 c xD. Yen and Euro both return correct values.
' A6 Q2 ?0 r. X+ j( f& i& OE. Compilation fails because of an error at line 25.
2 Q. Y$ g- t/ P& a! U1 LF. Compilation fails because of an error at line 30. Question 3 Given: 1. class TestA {
' V& _* R) O" G4 J. A2. public void start() { System.out.println(”TestA”); }
3 h0 Y; o1 x' i5 X3. }
2 f) q4 z& K' R4. public class TestB extends TestA { # w, K+ `! b/ [' q- q1 z1 X
5. public void start() { System.out.println(”TestB”); }
m: D" ^ I) X2 V6. public static void main(String[] args) {
: n, L9 N, x" P K6 g+ c" l7. ((TestA)new TestB()).start(); : H% v2 ^& t% G+ j* T
8. } ! e( v* R" N, b- z: T, |; d; m
9. }
) r! V5 n- A4 p1 S* ~+ J: E# p7 IWhat is the result? A. TestA # ^+ N" [2 [ Z. Z
B. TestB
1 u5 `& K2 z! AC. Compilation fails.
# v& h" ]5 X; h% T% OD. An exception is thrown at runtime. Question 4 Given: 11. public static void main(String[] args) {
6 j4 w5 `" {( V5 g8 Y- s% C12. String str = “null’; : d5 L! D" |, [$ e3 f
13. if (str == null) {
7 ?( {4 ^4 x7 D4 ~" s14. System.out.println(”null”);
, y7 e8 d% P8 h, s15. } else (str.length() == 0) {
! Q9 Y3 h7 g m: A6 w% z5 }( W16. System.out.println(”zero”);
" \' m5 Y; ^: {17. } else { % I2 C! r. [! J3 L+ n
18. System.out.println(”some”); \9 B* R) d" W% T1 i
19. } ! Y- J4 }5 }! J( V2 Q: g7 `* |
20. } - V5 d$ C* W/ ?8 ^. R; U! g1 c2 n0 q
‘What is the result? A. null 2 M! w7 ` s% G9 p( F
B. zero % J' G/ Y0 L E7 N: n$ i1 O; {
C. some
& J% G" p+ e+ f4 D9 CD. Compilation fails. ' J) h# K) P9 n5 O
E. An exception is thrown at runtime. Question 5 Given: 33. try {
8 N+ r. `. C! Z* {% I9 U4 |6 g34. // some code here
# y. m' C! ^/ ?8 Y8 M* u' d/ Z, D35. } catch (NullPointerException e1) {
! r Z7 V( D4 [; i' M7 m36. System.out.print(”a”);
( @1 q( `- m0 o6 |37. } catch (RuntimeException e2) {
$ G O& U8 t$ [# i7 q% s38. System.out.print(”b”);
/ Q- U4 ~6 J m7 S39. } finally {
* Z, N8 c5 x! U40. System.out.print(”c”); . A, G$ Z( n* c8 V, `
41. } 7 c8 ?" j: P! h H' E. q: a# z/ {
What is the result if a NullPointerException occurs on line 34? 6 M: N: K( G. a: w. K- G5 Z
A. c ) N T a7 e9 Z' p2 C7 c% ]
B. a ( U3 x& W" Y/ u/ }) o7 T. R/ q
C. ab
B$ i4 R' O0 E4 |: nD. ac
: _4 q/ o5 y, F) T' h' W$ m$ P; b# s+ S0 OE. bc 7 n- w: n1 B: j& j
F. abc Question 6 Given this method in a class: 21. public String toString() {
1 ?. F0 R( o! Z( D( s22. StringBuffer buffer = new StringBuffer(); , ~, l2 E; y/ x% ?. c5 E' V/ u
23. buffer.append(’<’); * P! U% K- c" C9 c9 F3 m$ f$ q6 w' ~7 a
24. buffer.append(this.name);
: ?* |9 ^/ Y: k! ?1 \- z5 q$ u# _25. buffer.append(’>’); % w1 [/ V/ }* b1 L) C$ Z
26. return buffer.toString(); $ x1 S3 k" ?5 O& [0 R) j" k+ d6 g
27. } d* i/ l8 `% y* i. q5 I
Which is true? A. This code is NOT thread-safe.
- G" `: @5 v$ M' s3 c% N$ cB. The programmer can replace StringBuffer with StringBuilder with no - W9 a2 _" x' I5 l# w4 E
other changes. : f3 p& h/ Z/ E3 c; {6 C
C. This code will perform well and converting the code to use
. h- P6 x2 D* y, _' N: T, j6 pStringBuilder will not enhance the performance.
& S! b0 w! k9 S; zD. This code will perform poorly. For better performance, the code 1 Q7 c Y. w, U& e
should be rewritten: return “<“+ this.name + “>”; Question 7 Given: 14. DateFormat df; ' F+ j! w! x0 r Z0 y9 a( [
15. Date date = new Date();
5 F* {7 e; j2 q0 a* |) j+ @" e3 t% A16. //insert code here
4 h' p) t& a% ?$ m; G) E2 R17. String s = df.format( date); 2 c# v. F9 L$ ]8 M+ l& C5 \9 E2 {
Which two, inserted independently at line 16, allow the code to compile? (Choose two.) A. df= new DateFormat();
+ q( I+ p: a8 g# ?4 JB. df= Date.getFormatter(); . H0 W. Z7 }0 }4 \, I9 k, y
C. df= date.getFormatter(); : }5 C3 s" s6 I" b
D. df= date.getDateFormatter(); 5 i2 }% J* V: l5 O1 z
E. df= Date.getDateFormatter(); 6 e+ G1 o- J, B
F. df= DateFormat.getInstance(); 3 U9 V) v: q) l# e, {3 J
G. df = DateFormat.getDateInstance(); Question 8 为数据库中一个或者多个表中的数据提供另外一种查看方式的逻辑表被称为()。(选择一项) A. 存储过程 B. 数据库关系图 C. 视图 D. 表 Question 9 已知employee表中具有默认约束df_email,删除该约束的语句为()。A. alter talbe employee drop constraint df_email B. alter talbe employee remove constraint df_email C. alter talbe employee delete constraint df_email D. remove constraint df_email from talbe employee Question 10 将E-R图转换为表的过程中,如果实体之间存在多对多的关系,通常的做法是()。 A. 在两个实体间建立主外键关系。 B. 在两个实体间建立关联表,把一个多对多的关系分解成两个一对多的关系。 C. 在两个实体间建立关联表,把一个多对多的关系分解成两个一对一的关系。 D. 在两个实体间不建立任何关系。 Question 11 假设有scores表的设计如下: ID(编号,主键) StudentID(学生编号) CourseID(课程编号) Score(分数) 现在要查询参加过至少两门课程考试的学生各门课程的平均成绩。以下SQL语句正确的是()。 A. select StudentID,avg(score) from scores group by StudentID having count(studentID)>1 B. select StudentID,avg(score) from scores group by StudentID where count(studentID)>1 C. select StudentID,avg(score) from scores group by StudentID where count(studentID)>1 group by StudentID D. select StudentID,avg(score) from scores having count(studentID)>1 Question 12 在()的列上更适合创建索引。 A. 需要对数据进行排序 B. 具有默认值 C. 频繁更改 D. 频繁搜索 Question 13 (hibernate)以下哪个选项不是持久化层的对象状态? A. 临时状态B. 独立状态C. 游离状态D. 持久化状态 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的执行流程。
+ ]8 B1 g5 g3 H |