|
谋学网(www.mouxue.com)是国内最专业的奥鹏作业资料,奥鹏离线作业资料及奥鹏毕业论文辅导型网站,主要提供奥鹏中医大、大工、东财、北语、北航、川大、南开等奥鹏作业资料辅导,致力打造中国最专业的远程教育辅导社区。
) R) |6 v( r0 t* t% b6 x" I7 U% C* j8 U2 V) z R
7 U, E% ? P" g- b; J8 J8 o3 d; `+ t7 b, M7 Z! m2 B( I$ h: z% F* k
一、单选题(共 20 道试题,共 60 分。)V 1. 下列语句序列执行后,k的值是( )。 int j=8, k=15; for( int i=2; i!=j; i++ ) { j-=2; k++; }9 c# r2 N' Z: [% l) \ @
A. 15
# G4 ~3 y4 C7 j" V' U& CB. 16* @2 ^2 W( H* m0 b
C. 17$ O! V( n9 u& j. M
D. 18
. t( ~1 K/ g I 满分:3 分
3 }2 {& ]$ L" G( c# L5 T4 H" C) g2. 下列语句序列执行后,j 的值是( )。 Int j=3, i=2; while( --i!=i/j ) j=j+2;
8 ?: f! p6 B8 |8 V% v) oA. 2
l6 k1 v6 l9 g" d6 Q8 pB. 4% e5 l# p3 |2 z% f& K; ~" _
C. 50 p, B* @ I- L" s$ l, A/ h
D. 6$ y9 n0 ]5 p/ h( f7 c4 B) N
满分:3 分* n4 _+ F3 C9 F" }* i7 [
3. 阅读下列代码后 public class Person{ int arr[]=new int[10]; public static void main(String args[]){ System.out.println(arr[1]); } } 正确的说法是
. m/ U* F- h1 |6 v! }A. 编译时将产生错误
# M3 M/ J+ u( q0 h: FB. 编译时正确,运行时将产生错误+ r r% I! E8 ~
C. 输出零) M* p' y9 ~2 c# r! N
D. 输出空, e' _2 Y r: O" ]9 s$ l
满分:3 分
8 f5 d5 ~4 E9 ~! c7 }4. 下面哪一个类可以访问foo包中的所有变量? package foo; class a{int c} class b{private int d} class c{public int e}
+ ~& o, j9 G) x0 oA. class a
0 B$ i6 S8 `; ~. PB. class b
8 p: o+ K1 w' x) d) N3 {/ f$ CC. class c; R( a: s8 Q0 t+ s( |$ D- Q- e; g
D. 都不能; k8 M$ I6 q% Z; f$ t
满分:3 分0 O3 `* s" `/ ]0 X- H
5. 65. 已知有下列类的说明,则下列哪个语句是正确的? public class Test { private float f = 1.0f; int m = 12; static int n=1; public static void main(String arg[]) { Test t = new Test(); } }$ a8 Q' q ]7 u6 P1 }
A. t.f;
5 m. j. P! j3 r% a$ n! w3 HB. this.n;
* Y7 E2 V( D& s, S$ AC. Test.m;' y" |9 N( q9 W- r# ?* |
D. Test.f;! P: x$ V! f2 U2 I4 }1 l
满分:3 分8 ]2 i- `# T r& I5 X
6. 为了获得参数lastname,在applet中可以写如下代码:
$ p( z7 v) t" b2 q- h' N% L) _A. String s=getName(“lastname”);
- m) H2 ^( L7 i0 o( HB. String s=parameter(“lastname”);
. ?* B9 @7 J2 V# CC. String s=getParameter(“lastname”);% ? f5 z( v s+ U" w4 N. L' I$ I
D. 9 {% v% ?+ j: P1 K& Y" ^) }# ?& o
满分:3 分
3 y0 X* }3 z/ ^) Z o0 J7. 下列代码中,将引起一个编译错误的行是 1)public class Test{ 2) int m,n; 3) public Test() {} 4) public Test(int a) {m=a;} 5) public static void main(String args[]){ 6) Test t1,t2; 7) int j,k; 8) j=0;k=0; 9) t1=new Test(); 10) t2=new Test(j,k); 11) } 12$ Q7 n! z- G" C3 \) l& \3 W
A. 第3行
# E5 b6 L. ^1 D) M" b6 @B. 第5行
5 {# v' S, W* o) @C. 第6行: z. z3 ?* R' K; [
D. 第10行: j3 a, s9 ] ~1 c0 e, m3 @( B" V
满分:3 分
' w8 V1 ?' ~# X3 y- M( y& n8. 选择正确的叙述. class Happy extends Frame { Happy() { SetLayout(new GridLayout(2,2)); Panel p1 = new Panel(); add(p1); p1.add( new Button("One")); Panel p2 = new Panel(); add(p2); p2.add( new Button("Two")); add( new Button("Three")); add( new Button("Four")); s
" L1 N( v; O/ K4 IA. 当frame调整大小时,按钮Three和Four 的大小也将调整。/ ^' H& q6 _; F" }' `
B. 当frame调整大小时,所有按钮的大小都将调整。0 n) E' b0 X: G
C. 当frame调整大小时,按钮Two和Four 的大小也将调整。
* S h# a+ S, q" ]D. 当frame调整大小时,按钮One和Two 的大小也将调整。
5 G4 q2 P4 z) _" o, Q6 ?$ ~0 E, g 满分:3 分0 \$ x5 u' r& L! \- m4 Q: [
9. 给出下面的接口: interface A{ int method1(int i); int method2(int j); } 下面那个类实现了这个接口,并且不是抽象的?- x! {: y0 e* W
A. class B implements A{ int method1(){} int method2(){} }" X5 H' U( q. G
B. class B { int method1(int i){} int method2(int j){} }
3 P5 O: e7 a# p+ F. a6 mC. class B implements A{ int method1(int i){} int method2(int j){} }. d6 X# ^ S% F: J) @
D. class B extends A{ int method1(int i){} int method2(int j){} }
) S' c! M$ y- i& h& m" J2 M( G 满分:3 分$ x' }. n, [: F$ p$ x1 y
10. 如果你试图编译下面的代码会发生什么事? Class MyString extends String{ }
( X0 p9 u! l3 ~; P% R6 FA. 代码编译成功1 H6 A! U, g3 d3 n! }
B. 代码不能编译,因为没有定义一个main()方法
: f& G, \" w& v6 PC. 代码不能编译,因为String是abstract类型的
7 h( j9 ^# j; sD. 代码不能编译,因为String是final类型的
8 F6 m/ @3 c; a! e0 K Q! b 满分:3 分
( y& T$ g$ C% S) w( C; C+ ~2 L F% P11. 下面程序的输出结果是什么? class Happy { public static void main(String args[]) { int i =1; int j = 10; do { if ( i++ < j--) continue; } while ( i <5 ); System.out.println ( i+" "+j ); } }
8 u0 f) u- ~1 k+ kA. 5 5
% U M( P# u' @! Q6 t& `7 WB. 5 4
( g5 d' [$ L& w4 g) S1 RC. 6 4& i4 u1 }% r- D7 M8 Z0 N G7 d, r3 N
D. 5 6- @% v+ ?1 h4 Y6 T/ w/ o& a6 e
满分:3 分
2 G- R* c6 r1 z: G( t4 m12. 已知如下代码: boolean m = true; if ( m = false ) System.out.println("False"); else System.out.println("True"); 执行结果是什么?" t& E2 w$ _: o4 R @5 X
A. False
. K5 z3 Q4 i' a2 XB. True3 S9 r6 A8 C. }9 [& F0 W
C. 编译时出错
3 `9 {, U6 u7 q+ l6 ND. 运行时出错
7 G$ C0 }6 O+ q J4 z; \" e, y 满分:3 分
6 C6 Y# m( L f" n13. 下面程序的输出结果是什么? String s= "ABCD"; s.concat("E"); s.replace('C','F'); System.out.println(s);
" W+ m" b0 C' Y8 `8 H* j) PA. 编译错误,字符串是不可改变的- r( z8 }* i( G+ w7 k! p; _
B. ABFDE* {$ U& s% B- z% Q9 f
C. ABCDE
, w3 ?) ?7 g; `- r$ j9 U7 YD. ABCD
, S* ^# w7 U& q4 b" w+ | 满分:3 分
& O a |* i# o6 \14. 给出下列代码,则数组初始化中哪项是不正确的? byte[] array1,array2[]; byte array3[][]; byte [][] array4;
- @# e7 z5 v3 v/ p% ^A. array2 = array1
% I. U) ~8 m% T8 k6 }7 |% M# c- \2 ?* eB. array2=array3
) P5 O0 T- T* D. j9 aC. array2=array4; u) r$ R9 ~: B" b, U# S0 b
D. array3=array4' c3 Q" j- ?0 u
满分:3 分
, w# i+ \7 j- |+ }5 h15. 给定下面的类: public class Example{ String str=new String(“good”); char ch[]={'a','b','c'}; public static void main(String args[]){ Example ex=new Example(); ex.change(ex.str,ex.ch); System.out.println(ex.str+”and”+ex.ch); } public void
! S$ ^& u8 v5 m6 G; `3 O& [A. good and abc1 [1 q% d5 @# W0 B5 H. f J6 |
B. good and gbc
5 ~8 P: }2 I8 r+ FC. test ok and abc
+ R& z: u' `' w8 g3 XD. test ok and gbc& Q$ R- S) w# G
满分:3 分
1 H, w4 P. V& k( \16. 下面的语句的作用是:( )。 Vector MyVector = new Vector(100,50);
7 O+ j* M6 N* H1 [$ bA. 创建一个数组类对象MyVector,有100个元素的空间,每个元素的初值为50。
6 ] a: E J: ^, w4 l; _B. 创建一个向量类对象MyVector,有100个元素的空间,每个元素的初值为50。' f! f3 Z* L+ T9 q0 z% E7 c
C. 创建一个数组类对象MyVector,有100个元素的空间,若空间使用完时,以50个元素空间单位递增。
; w/ A1 L, o- ?2 tD. 创建一个向量类对象MyVector,有100个元素的空间,若空间使用完时,以50个元素空间单位递增。# O% a* D& R4 d. N3 v. M! N
满分:3 分
, p) J, m0 k9 z, T* S17. 下列语句序列执行后,k 的值是( )。 int x=6, y=10, k=5; switch( x%y ) { case 0: k=x*y; case 6: k=x/y; case 12: k=x-y; default: k=x*y-x; }
+ Q/ N0 {* s* w% Y& XA. 60; Q. U$ _0 z2 u1 y
B. 54$ y6 D( a Z" l
C. 0" F& @3 ?' J+ d' y+ u" E
D. 5
) J' l- l. J( y' {3 g0 ^; a 满分:3 分5 d2 ]9 i+ c$ z% o j. `3 f0 r
18. 已知如下的命令执行 java MyTest a b c 请问哪个语句是正确的?% s8 @, [2 |# T% D5 V, }& e
A. args[0] = "MyTest a b c"8 i7 n7 o& {1 S/ B5 G. n3 P
B. args[0] = "MyTest"
5 `0 I% ~0 E9 e; ]2 F. b3 MC. args[0] = "a"
* l* o$ \9 G8 B: J0 n4 h' T }9 T" J+ K' aD. args[1]= 'b'# z7 p! v; o8 }$ L! H) k% Q% S
满分:3 分
1 o1 F0 c! l/ H7 t$ A4 ?5 e/ c; q1 D" {19. 设有下面的一个类定义: class AA { static void Show( ){ System.out.println("我喜欢Java!"); } } class BB { void Show( ){ System.out.println("我喜欢C++!"); } } 若已经使用AA类创建对象a和BB类创建对象b,则下面哪一个方法调用是正确的:( )
# a# o$ s. ?( ?1 g2 f0 lA. a.Show( ) b.Show( )
% o( M0 ~8 {5 @ m$ E6 EB. AA.Show( ) BB.Show( )' b: i9 N6 ]$ }. S) C% b
C. AA.Show( ) b.Show( )
* G( e4 I4 r. XD. a.Show( ) BB.Show( )
! d. l2 I2 z$ }; `0 m% V 满分:3 分
& R" [" f1 H3 W8 N20. 设有下面两个类的定义: class Person { long id; // 身份证号 String name; // 姓名 } class Student extends Person { int score; // 入学总分 int getScore(){ re) r& \, X( r1 `0 z- M0 W2 X' Y
A. 包含关系
; O4 x: u9 q P( ?" w, ]; ^B. 继承关系2 [' [4 h- `! e5 V3 V3 L% v
C. 关联关系
: J/ k5 L9 Z- S- jD. 无关系,上述类定义有语法错误- B9 q/ |0 w$ ^% D
满分:3 分
' S7 H9 `1 d* G: T0 K
" W, J$ w9 J4 w2 b$ k二、多选题(共 10 道试题,共 40 分。)V 1. 你怎样从下面main()的调用中访问单词“kiss”? java lyrics a kiss is but a kiss
( {; @1 _6 t1 W7 {% }( zA. args[0]
$ O" `1 c# T9 [: B6 z' ?B. args[1]
# E( Z9 \9 M! ^; H& x& |; zC. args[2]+ y+ P6 n" W; H# x. V( |" a1 A! g
D. args[3]! R: p8 l9 s1 X& p9 k* {
E. args[4]
0 h+ i" a4 ^9 M' [F. args[5]
: K8 V9 I4 W" [- R3 ^$ N( u 满分:4 分
& }: [# w7 _! c0 C/ B2. 已知如下类说明: public class Test { private float f = 1.0f; int m = 12; static int n=1; public static void main(String arg[]) { Test t = new Test(); // 程序代码… } } 如下哪个使用是正确的?# J8 u* T- y1 R( ~- `8 r7 }+ a; X
A. t.f
3 v9 W) u1 B+ ZB. this.n
4 `9 Z, r6 ~* ]5 ~C. Test.m$ G$ l" N! S+ h: ?" y5 s0 v: G
D. Test.n- l$ E9 e" D2 p" M! T$ P
满分:4 分1 ~2 o; j7 s/ F8 K1 [
3. 在如下源代码文件Test.java中, 哪个是正确的类定义?0 `9 F# `) r. J* h$ }# F. ?
A. public class test { public int x = 0; public test(int x) { this.x = x; } }( [. } l* e$ M! d# P+ [' a
B. public class Test{ public int x=0; public Test(int x) { this.x = x; } }
# `! y2 a6 ~% P8 p% A- l6 B4 uC. public class Test extends T1, T2 { public int x = 0; public Test (int x) { this.x = x; } }
. q: F. d4 |1 h$ \D. public class
% z5 ~) y9 X5 U: b! p- ? 满分:4 分
" A8 E {$ C7 l+ ^5 W4. 已知如下定义: String s = "story"; 下面哪些表达式是合法的?0 `& s% t5 l) B4 Y& p9 t
A. s += "books";% |- u# ]$ c; Z; k
B. char c = s[1];
' \" E- N7 D$ |& ?C. int len = s.length;& _8 U7 S4 H, R4 C" V, {9 G* t
D. String t = s.toLowerCase();
$ w+ f: S" i! [; C2 ~# [' a& T( ^ 满分:4 分
7 E% I9 w; F ~, L5. 如果有以下代码,哪几个数字能产生输出 "Test2" 的结果? Switch(x){ case 1: System.out.println("Test1"); case 2: case 3: System.out.println("Test2"); break;} System.out.println("Test3"); }- a( y/ [5 W5 r4 J5 t9 k5 x
A. 0
7 F$ w/ i* P1 Z0 c# O, ~- g- xB. 13 N0 e' t* B L# d; ?: `
C. 2: V7 h- ^) q3 u' Q
D. 36 _7 \; }4 s" o/ P$ q4 @
满分:4 分
: X0 P2 ~' L5 M5 J! Q6. 给出下面的代码段: public class Base{ int w, x, y ,z; public Base(int a,int b) { x=a; y=b; } public Base(int a, int b, int c, int d) { //赋值 x=a, y=b w=d; z=c; } } 在代码说明//赋值 x=a, y=b处写入如下哪几行代码是正确的?0 H" I! c C6 a S1 I: S* h" Z
A. Base(a,b)/ x z6 V) D+ G: W! Y
B. x=a,y=b;
7 }8 b/ H7 d: l, IC. x=a;y=b;3 K- {; I+ L! A: V& m) n0 s
D. this(a,b);
( K. [' S' ^6 l' O 满分:4 分5 N0 C8 T4 J; ~- y3 e; q1 q
7. 假定文件名是“Fred.java”,下面哪个是正确的类声明。, C: P: k" ]: X6 u6 C1 o
A. public class Fred{ public int x = 0; public Fred (int x){ this.x=x; } }
0 s. p6 c4 ~* }. FB. public class fred{ public int x = 0; public Fred (int x){ this.x=x; } }
/ ?! @: }0 L) x1 i% g8 tC. public class Fred extends MyBaseClass{ public int x = 0; }. M8 t4 H$ @2 n/ }. S" @
满分:4 分3 C7 v: Q% b/ R* `
8. 针对下面的程序,那些表达式的值是true? Class Aclass{ private long val; public Aclass(long v){val=v;} public static void main(String args[]){ Aclass x=new Aclass(10L); Aclass y=new Aclass(10L); Aclass z=y; long a=10L; int b=10; } }
5 N) W' W% c1 H; rA. a==b;( D) }' {/ r- r6 L1 k5 x" H S
B. a==x;
+ z6 z3 \0 `- ?7 s9 LC. y==z;
4 L" S3 U& @* q" vD. x==y;3 F K7 A9 b. p' V6 Y4 i) Y. D" h
E. a==10.0;
: B, b- @- b# i* l. g' T 满分:4 分
/ w' d N. w) l( C; R3 k1 ^) O3 p: _6 x9. 下面代码执行后的输出是什么? outer: for(int i=0;i<3; i++) inner: for(int j=0;j<2;j++) { if(j==1) continue outer; System.out.println(j+ “ and “+i); }
; p! I1 C( o8 i8 ^9 Z$ q' {) eA. 0 and 0
* ]8 W( r# G8 Y- @ G5 gB. 0 and 1
/ d& ?) d3 t0 }$ ]C. 0 and 2
, @! Y0 n+ ] k* qD. 1 and 0; {9 W$ y* B a; K% \
E. 1 and 1
" \* R8 D7 c6 _1 E/ }# N0 kF. 1 and 2 F! u' m9 a; F$ c
G. 2 and 0
# h* L k$ z# G# RH. 2 and 1
/ s+ d* D. J* [I. 2 and 2' j ?" T. b8 ?8 i5 N7 `
满分:4 分
- S$ A, |1 U4 b- |10. 已知如下代码: public class Test { public static void main(String arg[]) { int i = 5; do { System.out.println(i); } while (--i>5) System.out.println("finished"); } } 执行后的输出结果包括什么?, g% r# H1 R" }0 e7 m; n* j
A. 5& }. E; [8 b& R$ y9 j
B. 4
# p K: y/ {! g. h% l' @! ^C. 6
+ r3 }) O6 v0 u; L1 X! nD. finished
! |" `' n, @( G' ]1 _- V; d) VE. 什么都不输出
% ^7 \4 _( m. _ 满分:4 分
6 S' I4 D: L4 B2 h9 f5 _; o- ^2 A( v1 b, W- i2 k* m" }
谋学网(www.mouxue.com)是国内最专业的奥鹏作业资料,奥鹏离线作业资料及奥鹏毕业论文辅导型网站,主要提供奥鹏中医大、大工、东财、北语、北航、川大、南开等奥鹏作业资料辅导,致力打造中国最专业的远程教育辅导社区。
6 {/ |" J* R# w, q% @ |
|