奥鹏作业答案-谋学网-专业的奥鹏在线作业答案辅导网【官网】

 找回密码
 会员注册

微信登录,扫一扫

手机号码,快捷登录

VIP会员,3年作业免费下 !奥鹏作业,奥鹏毕业论文检测新手作业下载教程,充值问题没有找到答案,请在此处留言!
2022年5月最新全国统考资料投诉建议,加盟合作!点击这里给我发消息 点击这里给我发消息
奥鹏课程积分软件(2021年最新)
查看: 1823|回复: 0

东北大学15春学期《JAVA语言程序设计Ⅰ》在线作业123

[复制链接]
发表于 2015-4-2 11:52:37 | 显示全部楼层 |阅读模式
谋学网
& Z  c4 x( S" X1 B
15春学期《JAVA语言程序设计Ⅰ》在线作业1( k* T( ~8 A8 O' s3 L% x
: _0 f; N7 w' l% Y: o: K

5 f) _7 X) ~' d* P$ A+ \( r0 m9 J

7 R0 n1 v& d+ u; p) w' |6 R+ ~一、单选(共 20 道试题,共 60 分。)7 u3 t( j! V+ K- i7 f$ c1 u
. `4 b( l( E/ }4 t' X
1.  下面程序的输出结果是什么? class Foo{ static void change(String s){ s=s.replace('j','l'); } public static void main(String args[]){ String s="java"; change(s); System.out.println(s); } }6 T$ W) F% |7 ]7 z5 ?" X) _
A. lava
0 W6 h# p* P% G2 u  p( rB. java
. |; a  L( ^0 R" P3 @- Q$ R/ |C. 编译错误
  v7 d0 C7 ]2 ?2 E1 c  h& h- GD. 运行时出现异常
2 `6 z7 ^) l# N9 F$ j' T  L/ p正确资料:B' M5 `8 G5 K5 F. R: g& @8 O
2.  下面程序的输出结果是什么? class C1{ static int j=0; public void method(int a){ j++; } } class Test extends C1{ public int method(){ return j++; } public void result(){ method(j); System.out.println(j+method()); } public static void main(String args[]){ new Te, g0 ^5 v' k; x% v' G
A. 0$ Z( |  W$ Y- \- w" j
B. 1" B$ D/ y) B& K3 _( f# Y8 }/ S
C. 2, z0 w' d- G7 K  ~  g! X
D. 3
! T/ Z6 r; N! p正确资料:C/ p8 @" I9 C- G: Q4 G1 Q
3.  已知如下代码: public class Test { long a[] = new long[10]; public static void main ( String arg[] ) { System.out.println ( a[6] ); } } 请问哪个语句是正确的?
" I7 r* H1 |' mA. 输出结果是 null.
1 t' L* Q" I# Z' [% A$ bB. 输出结果是0% ^8 g5 S4 K+ s$ m  `3 b6 ^- T# O0 D4 s7 u
C. 编译时出错
) l, F; o% ~7 i) i0 UD. 运行时出错
: k, C7 q" }0 h8 ^8 s0 t: U  {4 A2 d正确资料:B) a  t, {. L5 B) o) d
4.  已知如下的命令执行 java MyTest a b c 请问哪个语句是正确的?8 H+ I+ Q% H) V# I; q
A. args[0] = "MyTest a b c"
7 [* U/ m- |! K$ O6 A/ y5 Q/ WB. args[0] = "MyTest"
. K9 c4 k$ D: j% X/ n7 ?C. args[0] = "a"3 @/ m( S# w: X$ c' v: @
D. args[1]= 'b'! v- O! I# F- ^% Z: T
正确资料:C
& c6 i( [! J# a# X% C8 H# P6 P  p/ P5.  在oneMethod()方法运行正常的情况下,程序段将输出什么? public void test() { try { oneMethod(); System.out.println("condition 1"); } catch (ArrayIndexOutOfBoundsException e) { System.out.println("condition 2"); } catch(Exception e) { System.out.println("condition 3");
) p& ?1 M- Z( Q$ Y) W, O" i! FA. condition 1
6 f& ~/ {2 x, v/ `( AB. condition 29 U( M0 S. a! Z$ @
C. condition 3
1 y' w% ?+ S$ J4 tD. condition 1 finally
  m$ A3 x/ \* {2 b正确资料:D
# ]$ k" j' g0 b6.  为了获得参数lastname,在applet中可以写如下代码:/ s) Z* v9 @: n) ^( O' @
A. String s=getName(“lastname”);
! q  o1 |7 R3 k' b% o0 ]B. String s=parameter(“lastname”);
6 V/ C5 `9 ^$ HC. String s=getParameter(“lastname”);( _9 b2 N. j5 k9 E7 a, @
D. + b8 n/ ^0 Z, h7 R7 c
正确资料:C  T# W) Z$ L  g
7.  已知表达式int m[] = {0, 1, 2, 3, 4, 5, 6 }; 下面哪个表达式的值与数组下标量总数相等?
  Q/ _- m& q" @/ |9 v$ UA. m.length()
) x, t" L6 U7 Q3 n; ^8 k- xB. m.length
# Y; Z/ d) I7 u' m) F* A4 `( iC. m.length()+1
! a* ^% q6 Z# AD. m.length+1
9 M' j8 r/ P+ n7 t. e6 n; G+ o正确资料:B+ K3 g0 P% G" e$ M" |$ E: F
8.  下列程序段执行后t5的结果是( )。int t1 = 9, t2 = 11, t3=8;int t4,t5;t4 = t1 > t2 ? t1 : t2+ t1;t5 = t4 > t3 ? t4 : t3;
- \+ s, K8 [9 e3 L# tA. 8' ~3 A  n$ X$ G1 @# Y1 e
B. 20: o( C, w" j8 S+ Z9 X' v
C. 11
/ }3 b4 p' M; ~$ w7 r/ aD. 96 V+ @5 y6 h7 ~( M! W. k
正确资料:B; R5 Z- g; D1 F7 Q. O( \
9.  若a的值为3时,下列程序段被执行后,c的值是多少?( ) c = 1; if ( a>0 ) if ( a>3 ) c = 2; else c = 3; else c = 4;/ d4 f! @; v" k
A. 1
! v( H' \" U; G) n1 p( o! k" E/ d+ _# p3 oB. 28 _% k: q- |1 _5 |
C. 3' M9 \( F2 B4 x$ I6 ?  t- j
D. 44 ]' }! C$ ]/ E' B
正确资料:C
+ h8 Y; Q2 Q" u0 C& p+ ^  W1 m10.  下面程序的输出结果是什么? 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 ~& j; X/ a. j( X" ]A. 5 5: K7 T# }: S/ {1 x4 n. i' w& c1 w
B. 5 4
9 P! P- ]- J, N; vC. 6 4
& H' u* @9 \7 W  G$ UD. 5 6
, v, k# [% M$ S& ~9 y( n# l& {正确资料:D
7 I# o7 X% P2 p2 S+ z0 S3 E" g. f11.  有下面的类:  public class Example{   static int x[]=new int[15];   public static void main(String args[]){   System.out.println(x[5]);   }   } 下面的那些说法是正确的。9 S1 [# d+ o" o5 I  g0 Y9 _
A. 编译时出错
, C, b" B- ]  N, cB. 运行时出错8 G: d3 R- W1 E5 C
C. 输出0) H. d% C$ {  k& f" i
D. 输出null
3 i) ^" p5 }5 L正确资料:C! W# j* D8 O' A! k+ a8 ^
12.  给定下面的类:  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
5 n0 n2 C, q0 E1 ], A1 oA. good and abc
2 q; y. j# M6 IB. good and gbc
, [8 o+ @, _0 m) V* E% I% S/ [% y. VC. test ok and abc
0 d: X5 A8 Q4 O$ v6 nD. test ok and gbc+ S/ k/ c7 r! _( }5 K2 r2 m
正确资料:B
2 L# c, t" k! M. i' `1 G5 g2 ?6 X13.  阅读下列代码后 public class Person{ int arr[]=new int[10]; public static void main(String args[]){ System.out.println(arr[1]); } } 正确的说法是" M2 U2 `/ D+ B& L
A. 编译时将产生错误6 P( O8 m) D$ i& |; S
B. 编译时正确,运行时将产生错误
- n. b2 V6 m, Y7 }5 kC. 输出零
/ X4 x. d% R4 W% p  Z# i! C  XD. 输出空
5 n2 m) _: \4 R  p; M+ S6 s正确资料:C
: q0 J" _( g0 A0 Y0 ?9 z  I# k% P14.  下面的哪些程序段可以正确地获得从命令行传递的参数的个数?
8 I6 ~& W- b- r4 x, lA. int count = args.length;. p( L: F1 A2 ?  V1 {
B. int count = args.length-1;9 _1 z% g/ J9 V- u
C. int count=0; while(args[count]!=null) count++;/ Y' H, {" C4 V
D. int count=0;while (!(args[count].equals(“”))) count++;
- f/ o% R' R6 U3 Y# ]正确资料:A
( T" ?1 }0 b- f/ K" l15.  在程序的源文件开始处有下面一行程序: package awt;; B$ a: d# g5 I. V; [8 Z
A. 结果是一个编译错误,因为Java已经定义了一个awt包6 g- T0 M# H3 k7 E' {) d
B. 说明这个文件里的所有的类都应该包含在java.awt包里
7 C" N% h$ B/ y! M. e( ?+ J; K& }' sC. 说明这个文件里的所有的类都应该包含在自己定义的awt包里, E- J6 ?2 b; h* H
D. 导入你自己定义的awt包里的所有类( P+ ~% e8 a( H, C4 X+ N
正确资料:C$ \* a1 x: E& f& |% E
16.  下列代码的执行结果是 public class Test { public int aMethod() { static int i=0; i++; System.out.println(i); } public static void main(String args[]) { Test test = new Test();# E: [6 Q( G) A/ u
A. 编译错误* E7 b/ h( E9 |
B. 0- ?+ h' N  z/ |  t, L
C. 1
9 s$ w+ u* L7 @# x: ^( i2 YD. 运行成功,但不输出
/ o+ ]* J4 \9 K3 W8 `/ t& p正确资料:A  o# c! y% L6 c; J+ L; K
17.  如果你试图编译下面的代码会发生什么事? Class MyString extends String{ }- Y- h7 t) p( T. N2 z$ j3 z/ F3 u
A. 代码编译成功
9 I! O  i3 D. {$ y/ SB. 代码不能编译,因为没有定义一个main()方法  G3 y$ w5 n5 z  k
C. 代码不能编译,因为String是abstract类型的3 O5 h/ ~3 m& D' O1 |+ @/ s
D. 代码不能编译,因为String是final类型的
  g% s# X, {5 F5 I5 [7 L" h正确资料:D+ Z) h+ R+ ~  [/ N, q7 T/ ^
18.  给出如下代码: class Test{   private int m;   public static void fun() {     // some code...   } } 如何使成员变量m被函数fun()直接访问?
1 D7 E! ]/ [  |# v7 ?1 ~1 U# MA. 将private int m 改为protected int m" Q7 ]7 {: A+ D7 B8 U; T
B. 将private int m 改为 public int m# o0 a. ^4 [& ?& e* I; |
C. 将private int m 改为 static int m- h* K5 {7 `( R9 ?; E3 ~
D. 将private int m 改为 int m
- l2 {3 h9 C8 M$ P( X! K) e正确资料:C
8 `* d5 G5 G" |3 u( M19.  给出下列代码,如何使成员变量m 被方法fun()直接访问? class Test { private int m; public static void fun() { ... } }$ E/ F( I' ^( C* B# R
A. 将private int m 改为protected int m
8 ^0 ]; I: Y9 m. cB. 将private int m 改为 public int m# u8 |! e" R6 b, P6 p
C. 将private int m 改为 static int m1 `+ h8 j. Z: B/ F1 M
D. 将private int m 改为 int m
( V: R) r# z. u' M; j9 ~% h正确资料:C* q: k, k) K' z! h1 f
20.  给出下列的代码,哪行在编译时可能会有错误? ① public void modify(){ ② int i, j, k; ③ i = 100; ④ while ( i > 0 ){ ⑤ j = i * 2; ⑥ System.out.println (" The value of j is " + j ); ⑦ k = k + 1; ⑧ } ⑨ }5 V$ y2 Q! _7 R# S; C
A. 4
" k0 W! @6 k: m1 GB. 64 V# ~( T5 Q4 J
C. 7- f  S' o; M, H& s* c
D. 8+ Q" Z+ @* t, o+ g7 [
正确资料:C
* B+ t5 P1 T, ^+ a2 ^0 L8 {4 |- J9 l6 i  ^
" F1 n8 e! J7 }  C8 v* _# F% Y
9 G9 p" @- q4 m/ ~; d, ^% S$ y
  g4 M0 M4 r  Q* d

4 \" a, T0 U$ g- k15春学期《JAVA语言程序设计Ⅰ》在线作业1. A& J( f# t- P0 |, u
3 W5 v7 r6 E/ {

" K1 b( t! S: _
& i% m9 C* C9 ]. y$ m3 v0 ~# a% {# a" a/ k
二、多选题(共 10 道试题,共 40 分。)# Y  c2 s0 P0 q4 ]3 p
* b7 P% h. L. q; ~7 G! m+ j
1.  如果有以下代码,哪几个数字能产生输出 "Test2" 的结果? Switch(x){ case 1: System.out.println("Test1"); case 2: case 3: System.out.println("Test2"); break;} System.out.println("Test3"); }3 ]0 L7 y& w9 [- [, M
A. 0
2 X8 C" w8 Y, w0 f) ^) g1 bB. 1, L" ?) ?) k# l* k4 S7 }  o! |) X
C. 2# x/ }6 a$ M9 ?/ I% f2 w6 W
D. 3
# O. t' y- t( z2 H- T8 s正确资料:BCD
0 E; Y( m0 X5 v6 M5 Z$ b5 @2.  已知如下代码: public class Test { public static void main(String arg[]) { int i = 5; do { System.out.println(i); } while (--i>5) System.out.println("finished"); } } 执行后的输出结果包括什么?4 ]7 |* Y/ k% d# w/ `4 Y" q
A. 58 H5 f  z3 R* J* [' Y5 t
B. 43 q. F9 P& n$ t$ s  S! p
C. 65 q0 ^& M; h; k3 [& }8 r
D. finished
9 Y6 j4 @: S, T% Z, jE. 什么都不输出
% H) y! h  \( n  w2 y正确资料:AD
' o* V3 T2 X# I' U1 e% n8 \3 G' F: e3.  下面的哪些程序片断可能导致错误。& n" {0 y+ \8 E! h+ u* P
A. String s="Gonewiththewind"; String t="good"; String k=s+t;
$ K8 E' K  z+ k! ]B. String s="Gonewiththewind"; String t; t=s[3]+"one";- T9 F* a; _  T5 x" h5 a; }
C. String s="Gonewiththewind"; String standard=s.toUpperCase();1 N$ z- `  |$ W/ v+ W0 ~
D. String s="homedirectory"; String t=s-"directory".
( n. G+ x- w& W: L2 D, U正确资料:BD- F0 m3 A8 \: ?0 g( t+ {$ p6 D
4.  已知如下代码: switch (m) { case 0: System.out.println("Condition 0"); case 1: System.out.println("Condition 1"); case 2: System.out.println("Condition 2"); case 3: System.out.println("Condition 3");break; default: System.out.println("Other Condition"); } 当m 的2 W1 R% Y4 l" E5 Z4 {+ R) a3 ^2 C' J
A. 0* p4 |) E/ s9 P& B$ p, L2 f
B. 10 y5 W. t& L5 P& B
C. 2; E8 Q' M+ L! L0 V3 @* }5 Y% z
D. 3" p, G! h5 X8 U: e# j, g
E. 4' N) Y6 K9 M+ `) y' x# Y
F. 以上都不是
1 P$ _5 t1 G2 ~; f9 K2 c正确资料:ABC
1 {& u0 C: n. L5.  你怎样从下面main()的调用中访问单词“kiss”? java lyrics a kiss is but a kiss
4 F. U7 q( ]# g. j4 lA. args[0]
: b/ `: d  a; wB. args[1]
2 l6 C4 d4 }. Y& UC. args[2]
+ u$ X$ w- f; \8 Z: c! d. DD. args[3]7 w/ _0 v6 V# b% Y$ k$ o. v
E. args[4]; q$ h& H1 F. i1 Q7 ?. G# A
F. args[5]9 V4 j" @- Y* K) ]- |8 i, V
正确资料:BF/ T8 T% I6 d. v; B0 u
6.  已知如下类定义: class Base { public Base (){ //... } public Base ( int m ){ //... } protected void fun( int n ){ //... } } public class Child extends Base{ // member methods } 如下哪句可以正确地加入子类中?- D0 _1 N- Z* d* D
A. private void fun( int n ){ //...}
, ^  f( a  V, y0 G' @B. void fun ( int n ){ //... }$ v" _- b9 V% Y3 x
C. protected void fun ( int n ) { //... }' p4 ^! G3 w3 K7 l
D. public void fun ( int n ) { //... }/ p' G" a2 n* y
正确资料:CD
9 w2 u, m4 t( A8 W7.  给出下面的代码段: 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处写入如下哪几行代码是正确的?" u. r8 N; r3 `4 W) u/ s
A. Base(a,b)
2 w5 [% g& F; I6 {. \7 V1 NB. x=a,y=b;
+ P# n3 t. h9 y' b2 u, Y( [) ]C. x=a;y=b;
+ ~6 k3 ?/ I, k, V5 Y6 s" I+ E; ^D. this(a,b);
# i! T* J: [2 K& c' x: J正确资料:CD0 T! q: l" D( W  r& y
8.  下面代码执行后的输出是什么? 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); }
& a+ i9 e; N& o# Z8 g! }A. 0 and 0
' _, \0 Y: m- X% d9 hB. 0 and 1  x8 Q; B, X. }+ D% k
C. 0 and 2& J. o( R4 l0 u  _
D. 1 and 0
( Z4 W  Y# i  L/ T$ C- K1 ~3 W* L" {E. 1 and 1
1 j  @) L: J9 s& f( T7 zF. 1 and 2% Q5 r- k' H9 {; f
G. 2 and 09 l# V: |% [4 |! W3 h
H. 2 and 1
& n+ p- g2 E8 W. l) A7 R  y! ZI. 2 and 2
% r5 H5 T" M7 z& |, s/ {0 p正确资料:ABC! s) K( f2 J) C8 y% z( ^
9.  假定文件名是“Fred.java”,下面哪个是正确的类声明。
2 ~$ e# w- q0 O7 uA. public class Fred{   public int x = 0;   public Fred (int x){   this.x=x;   }   }
& Q- n$ O' d/ Z6 ~3 H" Q" Z! uB. public class fred{   public int x = 0;   public Fred (int x){   this.x=x;   }   }
7 r) R7 ^9 C, K" V7 fC. public class Fred extends MyBaseClass{   public int x = 0; }" W* b7 u& U( b$ ]& b
正确资料:AC
3 M4 U& ?& p4 s" c9 H10.  请选出创建数组的正确语句。
  P9 ^5 l) {& Q- [) MA. float f[][] = new float[6][6];+ D% W, H) j2 Z/ q! K8 b4 ]
B. float []f[] = new float[6][6];
" ?/ X, \; A& \( @3 m3 yC. float f[][] = new float[][6];
1 G& p7 B. Y+ j+ TD. float [][]f = new float[6][6];# }1 j6 @4 E6 F* K; e
正确资料:ABD+ @2 w0 z. h6 ]. l1 M

: U( i" X7 o" U7 n; D
3 y. s* }# W, W) c! |/ ?# A- d
7 d; S% Q& }7 F9 ?& I6 y# R6 p- }# S, J) c' ^- W

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?会员注册

×
奥鹏作业答案,奥鹏在线作业答案
您需要登录后才可以回帖 登录 | 会员注册

本版积分规则

 
 
客服一
客服二
客服三
客服四
点这里给我发消息
点这里给我发消息
谋学网奥鹏同学群2
微信客服扫一扫

QQ|关于我们|联系方式|网站特点|加入VIP|加盟合作|投诉建议|法律申明|Archiver|小黑屋|奥鹏作业答案-谋学网 ( 湘ICP备2021015247号 )

GMT+8, 2024-4-27 03:37 , Processed in 0.126205 second(s), 24 queries .

Powered by Discuz! X3.5

Copyright © 2001-2023 Tencent Cloud.

快速回复 返回顶部 返回列表