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

所属学校:东北大学 科目:JAVA语言程序设计Ⅰ 2015-03-17 16:25:00
14春学期《JAVA语言程序设计Ⅰ》在线作业2
试卷总分:100 奥鹏学习网(aopeng123.cn) 发布
单选题
多选题
一、单选题(共 20 道试题,共 60 分。)
V
1. 下面的语句的作用是:( )。 Vector MyVector = new Vector(100,50);
A. 创建一个数组类对象MyVector,有100个元素的空间,每个元素的初值为50。
B. 创建一个向量类对象MyVector,有100个元素的空间,每个元素的初值为50。
C. 创建一个数组类对象MyVector,有100个元素的空间,若空间使用完时,以50个元素空间单位递增。
D. 创建一个向量类对象MyVector,有100个元素的空间,若空间使用完时,以50个元素空间单位递增。
此题选: D 满分:3 分
2. 下列代码中,将引起一个编译错误的行是 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
A. 第3行
B. 第5行
C. 第6行
D. 第10行
此题选: D 满分:3 分
3. 下面的哪些程序段可以正确地获得从命令行传递的参数的个数?
A. int count = args.length;
B. int count = args.length-1;
C. int count=0; while(args[count]!=null) count++;
D. int count=0;while (!(args[count].equals(“”))) count++;
需要购买答案的联系QQ:79691519满分:3 分
4. 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(); } }
A. t.f;
B. this.n;
C. Test.m;
D. Test.f;
需要购买答案的联系QQ:79691519满分:3 分
5. 给出下列代码,如何使成员变量m 被方法fun()直接访问? class Test { private int m; public static void fun() { ... } }
A. 将private int m 改为protected int m
B. 将private int m 改为 public int m
C. 将private int m 改为 static int m
D. 将private int m 改为 int m
需要购买答案的联系QQ:79691519满分:3 分
6. 下列语句序列执行后,k的值是( )。 int j=8, k=15; for( int i=2; i!=j; i++ ) { j-=2; k++; }
A. 15
B. 16
C. 17
D. 18
需要购买答案的联系QQ:79691519满分:3 分
7. 在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");
A. condition 1
B. condition 2
C. condition 3
D. condition 1 finally
此题选: D 满分:3 分
8. 若a的值为3时,下列程序段被执行后,c的值是多少?( ) c = 1; if ( a 0 ) if ( a 3 ) c = 2; else c = 3; else c = 4;
A. 1
B. 2
C. 3
D. 4
需要购买答案的联系QQ:79691519满分:3 分
9. 设有下面两个赋值语句: a = Integer.parseInt("1024"); b = Integer.valueOf("1024").intValue(); 下述说法正确的是( )。
A. a是整数类型变量,b是整数类对象。
B. a是整数类对象,b是整数类型变量。
C. a和b都是整数类对象并且它们的值相等。
D. a和b都是整数类型变量并且它们的值相等。
此题选: D 满分:3 分
10. 已知如下代码: public class Test { long a[] = new long[10]; public static void main ( String arg[] ) { System.out.println ( a[6] ); } } 请问哪个语句是正确的?
A. 输出结果是 null.
B. 输出结果是0
C. 编译时出错
D. 运行时出错
需要购买答案的联系QQ:79691519满分:3 分
11. 给定下面的类:  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
A. good and abc
B. good and gbc
C. test ok and abc
D. test ok and gbc
需要购买答案的联系QQ:79691519满分:3 分
12. 下列类头定义中,错误的是( )。
A. class x { .... }
B. public x extends y { .... }
C. public class x extends y { .... }
D. class x extends y implements y1 { .... }
需要购买答案的联系QQ:79691519满分:3 分
13. 下面哪一个类可以访问foo包中的所有变量? package foo; class a{int c} class b{private int d} class c{public int e}
A. class a
B. class b
C. class c
D. 都不能
需要购买答案的联系QQ:79691519满分:3 分
14. 下面程序运行后I的结果是什么? Class sree { fun(){ static int I =0; I++; } public static void main(String args[]) { sree obj=new sree(); obj.fun(); obj.fun(); }
A. 编译错误
B. 运行时错误
C. 1
D. 2
需要购买答案的联系QQ:79691519满分:3 分
15. 下面程序的输出结果是什么? 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); } }
A. lava
B. java
C. 编译错误
D. 运行时出现异常
需要购买答案的联系QQ:79691519满分:3 分
16. 下列语句序列执行后,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; }
A. 60
B. 54
C. 0
D. 5
需要购买答案的联系QQ:79691519满分:3 分
17. Person, Student 和Teacher 都是类名。这些类有以下继承关系。 Person -------------------- Student Teacher 并且在Java源代码中有如下表达式: Person p = new Student(); 如下哪个语句是正确的?
A. 这条语句是合法的
B. 这条语句是不合法的
C. 编译时出错
D. 编译正确但运行时出错
需要购买答案的联系QQ:79691519满分:3 分
18. 给出下面的接口: interface A{ int method1(int i); int method2(int j); } 下面那个类实现了这个接口,并且不是抽象的?
A. class B implements A{ int method1(){} int method2(){} }
B. class B { int method1(int i){} int method2(int j){} }
C. class B implements A{ int method1(int i){} int method2(int j){} }
D. class B extends A{ int method1(int i){} int method2(int j){} }
需要购买答案的联系QQ:79691519满分:3 分
19. 下列程序的功能是在监控台上每隔一秒钟显示一个字符串“Hello”,能够填写在程序中下划线位置,使程序完整并能正确运行的语句是 public class Test implements Runnable{ public static void main(String args[]){ Test t=new Test(); Thread tt=new Thread(t); tt.start(); } public void run(){ for(;;){ try{
A. sleep(1000) InterruptedException
B. sleep(1000) RuntimeException
C. Thread.sleep(1000) RuntimeException
D. Thread.sleep(1000) InterruptedException
此题选: D 满分:3 分
20. 已知表达式int m[] = {0, 1, 2, 3, 4, 5, 6 }; 下面哪个表达式的值与数组下标量总数相等?
A. m.length()
B. m.length
C. m.length()+1
D. m.length+1
需要购买答案的联系QQ:79691519满分:3 分
14春学期《JAVA语言程序设计Ⅰ》在线作业2
试卷总分:100 奥鹏学习网(aopeng123.cn) 发布
单选题
多选题
二、多选题(共 10 道试题,共 40 分。)
V
1. 你怎样从下面main()的调用中访问单词“kiss”? java lyrics a kiss is but a kiss
A. args[0]
B. args[1]
C. args[2]
D. args[3]
E. args[4]
F. args[5]
需要购买答案的联系QQ:79691519满分:4 分
2. String s=”Example String”; 下面哪些语句是正确的?
A. s =3;
B. int i=s.length();
C. s[3]=”x”;
D. String short_s=s.trim();
E. String t=”root”+s;
需要购买答案的联系QQ:79691519满分:4 分
3. 下面代码执行后的输出是什么? 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. 0 and 0
B. 0 and 1
C. 0 and 2
D. 1 and 0
E. 1 and 1
F. 1 and 2
G. 2 and 0
H. 2 and 1
I. 2 and 2
需要购买答案的联系QQ:79691519满分:4 分
4. 针对下面的程序,那些表达式的值是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;   }   }
A. a==b;
B. a==x;
C. y==z;
D. x==y;
E. a==10.0;
需要购买答案的联系QQ:79691519满分:4 分
5. 下面的哪些程序片断可能导致错误。
A. String s="Gonewiththewind"; String t="good"; String k=s+t;
B. String s="Gonewiththewind"; String t; t=s[3]+"one";
C. String s="Gonewiththewind"; String standard=s.toUpperCase();
D. String s="homedirectory"; String t=s-"directory".
需要购买答案的联系QQ:79691519满分:4 分
6. 已知如下代码: 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 的
A. 0
B. 1
C. 2
D. 3
E. 4
F. 以上都不是
需要购买答案的联系QQ:79691519满分:4 分
7. 如果有以下代码,哪几个数字能产生输出 "Test2" 的结果? Switch(x){ case 1: System.out.println("Test1"); case 2: case 3: System.out.println("Test2"); break;} System.out.println("Test3"); }
A. 0
B. 1
C. 2
D. 3
需要购买答案的联系QQ:79691519满分:4 分
8. 选择所有有效的构造函数。 class Happy { } }
A. public void Happy(){}
B. public Happy(int c){}
C. protected Happy(){}
D. public int Happy(){}
E. void Happy(){}
需要购买答案的联系QQ:79691519满分:4 分
9. 给出下面的代码段: 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处写入如下哪几行代码是正确的?
A. Base(a,b)
B. x=a,y=b;
C. x=a;y=b;
D. this(a,b);
需要购买答案的联系QQ:79691519满分:4 分
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"); } } 执行后的输出结果包括什么?
A. 5
B. 4
C. 6
D. finished
E. 什么都不输出
需要购买答案的联系QQ:79691519满分:4 分
版权声明

声明:有的资源均来自网络转载,版权归原作者所有,如有侵犯到您的权益 请联系本站我们将配合处理!

分享: