黄老师 发表于 2016-3-21 09:01:37

东北大学16春学期《JAVA语言程序设计Ⅰ》在线作业参考答案

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

一、单选题:
1.如果你试图编译下面的代码会发生什么事?Class MyString extends String{}          (满分:3)
    A. 代码编译成功
    B. 代码不能编译,因为没有定义一个main(    )方法
    C. 代码不能编译,因为String是abstract类型的
    D. 代码不能编译,因为String是final类型的
2.下面程序的输出结果是什么?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 );}}          (满分:3)
    A. 5 5
    B. 5 4
    C. 6 4
    D. 5 6
3.阅读下列代码后public class Person{int arr[]=new int;public static void main(String args[]){System.out.println(arr);}}正确的说法是          (满分:3)
    A. 编译时将产生错误
    B. 编译时正确,运行时将产生错误
    C. 输出零
    D. 输出空
4.若a的值为3时,下列程序段被执行后,c的值是多少?(    )   c = 1;   if ( a>0 )if ( a>3 )c = 2;   else   c = 3;    else   c = 4;          (满分:3)
    A. 1
    B. 2
    C. 3
    D. 4
5.下面程序的输出结果是什么? 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); } }          (满分:3)
    A. lava
    B. java
    C. 编译错误
    D. 运行时出现异常
6.下面的哪些程序段可以正确地获得从命令行传递的参数的个数?          (满分:3)
    A. int count = args.length;
    B. int count = args.length-1;
    C. int count=0; while(args!=null) count++;
    D. int count=0;while(!(args.equals(“”))) count++;
7.下列程序段执行后t5的结果是(    )。int t1 = 9, t2 = 11, t3=8;int t4,t5;t4 = t1 > t2 ? t1 : t2+ t1;t5 = t4 > t3 ? t4 : t3;          (满分:3)
    A. 8
    B. 20
    C. 11
    D. 9
8.给出如下代码:class Test{  private int m;  public static void fun(    ) {    // some code...  }}如何使成员变量m被函数fun(    )直接访问?          (满分:3)
    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
9.下列类头定义中,错误的是(    )。          (满分:3)
    A. class x    { .... }
    B. public x extends y   { .... }
    C. public class x extends y   { .... }
    D. class x extends y implements y1   { .... }
10.下面程序的输出结果是什么?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          (满分:3)
    A. 0
    B. 1
    C. 2
    D. 3
11.如果你要读一个参数值,而该参数在标签内没有定义,则会:          (满分:3)
    A. 运行时抛出异常
    B. 参数值为空
    C. 参数值是个空字符串
    D.
12.下面语句返回的数据类型是什么?(short)10/10.2*2;          (满分:3)
    A. int
    B. double
    C. float
    D. short
13.下列代码的执行结果是 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(    );          (满分:3)
    A. 编译错误
    B. 0
    C. 1
    D. 运行成功,但不输出
14.如果你有下面的类定义abstract class Shape{                abstract void draw(    );}请问,在试图编译下面的类定义时会发生什么情况?class Square extends Shape{}          (满分:3)
    A. 都可以成功编译
    B. Shpe可以编译,而Square不能
    C. Square可以编译,而Shape不能
    D. Shape和Square都不能编译
15.有下面的类:  public class Example{   static int x[]=new int;   public static void main(String args[]){   System.out.println(x);   }   } 下面的那些说法是正确的。          (满分:3)
    A. 编译时出错
    B. 运行时出错
    C. 输出0
    D. 输出null
16.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(    ); } }          (满分:3)
    A. t.f;
    B. this.n;
    C. Test.m;
    D. Test.f;
17.下面程序运行后I的结果是什么?Class sree{fun(    ){static int I =0;I++;}public static void main(String args[]){sree obj=new sree(    );obj.fun(    );obj.fun(    );}          (满分:3)
    A. 编译错误
    B. 运行时错误
    C. 1
    D. 2
18.给出下面的接口:interface A{        int method1(int i);        int method2(int j);}下面那个类实现了这个接口,并且不是抽象的?          (满分:3)
    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){}}
19.下面程序的输出结果是什么?public static void main(String args[]){int a=10;int b=20;if(a=b)System.out.println("Not Equal");elseSystem.out.println("Equal");}          (满分:3)
    A. Equal
    B. Not Equal
    C. 编译错误
    D. 运行时将抛出异常
20.以下代码的输出结果是什么?class Foo{public static void main(String args[]){int x=4,j=0;switch(x){case 1:j++;case 2:j++;case 3:j++;case 4:j++;case 5:j++;break;default:j++;}System.out.println(j);}}          (满分:3)
    A. 1
    B. 2
    C. 3
    D. 编译错误
二、多选题:
1.已知如下类说明: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(    );// 程序代码…} }如下哪个使用是正确的?          (满分:4)
    A. t.f
    B. this.n
    C. Test.m
    D. Test.n
2.针对下面的程序,那些表达式的值是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;   }   }          (满分:4)
    A. a==b;
    B. a==x;
    C. y==z;
    D. x==y;
    E. a==10.0;
3.请选出创建数组的正确语句。          (满分:4)
    A. float f[][] = new float;
    B. float []f[] = new float;
    C. float f[][] = new float[];
    D. float [][]f = new float;
4.你怎样从下面main(    )的调用中访问单词“kiss”?java lyrics a kiss is but a kiss          (满分:4)
    A. args
    B. args
    C. args
    D. args
    E. args
    F. args
5.已知如下定义:String s = "story";下面哪些表达式是合法的?          (满分:4)
    A. s += "books";
    B. char c = s;
    C. int len = s.length;
    D. String t = s.toLowerCase(    );
6.假定文件名是“Fred.java”,下面哪个是正确的类声明。          (满分:4)
    A. public class Fred{   public int x = 0;   public Fred(int x){   this.x=x;   }   }
    B. public class fred{   public int x = 0;   public Fred(int x){   this.x=x;   }   }
    C. public class Fred extends MyBaseClass{   public int x = 0; }
7.给出下面的代码段: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=bw=d;z=c;}}在代码说明//赋值 x=a, y=b处写入如下哪几行代码是正确的?          (满分:4)
    A. Base(a
    b)
    B. x=a
    y=b;
    C. x=a;y=b;
    D. this(a
    b);
8.String s=”Example String”; 下面哪些语句是正确的?          (满分:4)
    A. s>>>=3;
    B. int i=s.length(    );
    C. s=”x”;
    D. String shorts=s.trim(    );
    E. String t=”root”+s;
9.已知如下代码: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)
    A. 5
    B. 4
    C. 6
    D. finished
    E. 什么都不输出
10.如果有以下代码,哪几个数字能产生输出 "Test2" 的结果?Switch(x){case 1: System.out.println("Test1");case 2:case 3: System.out.println("Test2");break;}System.out.println("Test3");}          (满分:4)
    A. 0
    B. 1
    C. 2
    D. 3
16春学期《JAVA语言程序设计Ⅰ》在线作业2

一、单选题:
1.为了获得参数lastname,在applet中可以写如下代码:          (满分:3)
    A. String s=getName(“lastname”);
    B. String s=parameter(“lastname”);
    C. String s=getParameter(“lastname”);
    D.
2.若有循环:int x=5,y=20;do{    y-=x;   x++;}while(++x<--y);则循环体将被执行(    )。          (满分:3)
    A. 0次
    B. 1次
    C. 2次
    D. 3次
3.下列类头定义中,错误的是(    )。          (满分:3)
    A. class x    { .... }
    B. public x extends y   { .... }
    C. public class x extends y   { .... }
    D. class x extends y implements y1   { .... }
4.下列语句序列执行后,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;}          (满分:3)
    A. 60
    B. 54
    C. 0
    D. 5
5.在程序的源文件开始处有下面一行程序:package awt;          (满分:3)
    A. 结果是一个编译错误,因为Java已经定义了一个awt包
    B. 说明这个文件里的所有的类都应该包含在java.awt包里
    C. 说明这个文件里的所有的类都应该包含在自己定义的awt包里
    D. 导入你自己定义的awt包里的所有类
6.已知表达式int m[] = {0, 1, 2, 3, 4, 5, 6 };下面哪个表达式的值与数组下标量总数相等?          (满分:3)
    A. m.length(    )
    B. m.length
    C. m.length(    )+1
    D. m.length+1
7.下列语句序列执行后,j 的值是(    )。Int j=3, i=2;while( --i!=i/j )    j=j+2;          (满分:3)
    A. 2
    B. 4
    C. 5
    D. 6
8.下面程序运行后I的结果是什么?Class sree{fun(    ){static int I =0;I++;}public static void main(String args[]){sree obj=new sree(    );obj.fun(    );obj.fun(    );}          (满分:3)
    A. 编译错误
    B. 运行时错误
    C. 1
    D. 2
9.下面程序的输出结果是什么?String s= "ABCD";s.concat("E");s.replace('C','F');System.out.println(s);          (满分:3)
    A. 编译错误,字符串是不可改变的
    B. ABFDE
    C. ABCDE
    D. ABCD
10.下面的语句的作用是:(    )。    VectorMyVector = newVector(100,50);          (满分:3)
    A. 创建一个数组类对象MyVector,有100个元素的空间,每个元素的初值为50。
    B. 创建一个向量类对象MyVector,有100个元素的空间,每个元素的初值为50。
    C. 创建一个数组类对象MyVector,有100个元素的空间,若空间使用完时,以50个元素空间单位递增。
    D. 创建一个向量类对象MyVector,有100个元素的空间,若空间使用完时,以50个元素空间单位递增。
11.下列程序的功能是在监控台上每隔一秒钟显示一个字符串“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{          (满分:3)
    A. sleep(1000)InterruptedException
    B. sleep(1000)RuntimeException
    C. Thread.sleep(1000)RuntimeException
    D. Thread.sleep(1000)InterruptedException
12.下面程序的输出结果是什么?public static void main(String args[]){int a=10;int b=20;if(a=b)System.out.println("Not Equal");elseSystem.out.println("Equal");}          (满分:3)
    A. Equal
    B. Not Equal
    C. 编译错误
    D. 运行时将抛出异常
13.下列哪个选项的java源文件代码片段是不正确的?          (满分:3)
    A. package testpackage; public class Test{ }
    B. import java.io.*; package testpackage; public class Test{ }
    C. import java.io.*; class Person{ } public class Test{ }
    D. import java.io.*; import java.awt.*; public class Test{ }
14.顺序执行下列程序语句后,则b的值是 String a="Hello"; String b=a.substring(0,2);          (满分:3)
    A. Hello
    B. hello
    C. Hel
    D. null
15.下面程序的输出结果是什么?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 );}}          (满分:3)
    A. 5 5
    B. 5 4
    C. 6 4
    D. 5 6
16.设有下面两个赋值语句:      a = Integer.parseInt("1024");      b = Integer.valueOf("1024").intValue(    );   下述说法正确的是(    )。          (满分:3)
    A. a是整数类型变量,b是整数类对象。
    B. a是整数类对象,b是整数类型变量。
    C. a和b都是整数类对象并且它们的值相等。
    D. a和b都是整数类型变量并且它们的值相等。
17.如果你要读一个参数值,而该参数在标签内没有定义,则会:          (满分:3)
    A. 运行时抛出异常
    B. 参数值为空
    C. 参数值是个空字符串
    D.
18.下列程序段执行后t5的结果是(    )。int t1 = 9, t2 = 11, t3=8;int t4,t5;t4 = t1 > t2 ? t1 : t2+ t1;t5 = t4 > t3 ? t4 : t3;          (满分:3)
    A. 8
    B. 20
    C. 11
    D. 9
19.下列语句序列执行后,a的值是(    )。int a=13; a%=a/5;          (满分:3)
    A. 3
    B. 13
    C. 1
    D. 169
20.选择正确的叙述.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          (满分:3)
    A. 当frame调整大小时,按钮Three和Four 的大小也将调整。
    B. 当frame调整大小时,所有按钮的大小都将调整。
    C. 当frame调整大小时,按钮Two和Four 的大小也将调整。
    D. 当frame调整大小时,按钮One和Two 的大小也将调整。
二、多选题:
1.请选出创建数组的正确语句。          (满分:4)
    A. float f[][] = new float;
    B. float []f[] = new float;
    C. float f[][] = new float[];
    D. float [][]f = new float;
2.给出下面的代码段: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=bw=d;z=c;}}在代码说明//赋值 x=a, y=b处写入如下哪几行代码是正确的?          (满分:4)
    A. Base(a
    b)
    B. x=a
    y=b;
    C. x=a;y=b;
    D. this(a
    b);
3.已知如下类说明: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(    );// 程序代码…} }如下哪个使用是正确的?          (满分:4)
    A. t.f
    B. this.n
    C. Test.m
    D. Test.n
4.已知如下定义:String s = "story";下面哪些表达式是合法的?          (满分:4)
    A. s += "books";
    B. char c = s;
    C. int len = s.length;
    D. String t = s.toLowerCase(    );
5.选择所有有效的构造函数。class Happy {}}          (满分:4)
    A. public void Happy(    ){}
    B. public Happy(int c){}
    C. protected Happy(    ){}
    D. public int Happy(    ){}
    E. void Happy(    ){}
6.已知如下类定义:class Base {public Base(    ){ //... }public Base( int m ){ //... }protected void fun( int n ){ //... }}public class Child extends Base{// member methods}如下哪句可以正确地加入子类中?          (满分:4)
    A. private void fun( int n ){ //...}
    B. void fun( int n ){ //... }
    C. protected void fun( int n ) { //... }
    D. public void fun( int n ) { //... }
7.如果有以下代码,哪几个数字能产生输出 "Test2" 的结果?Switch(x){case 1: System.out.println("Test1");case 2:case 3: System.out.println("Test2");break;}System.out.println("Test3");}          (满分:4)
    A. 0
    B. 1
    C. 2
    D. 3
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);}          (满分:4)
    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
9.下面的哪些程序片断可能导致错误。          (满分:4)
    A. String s="Gonewiththewind";String t="good";String k=s+t;
    B. String s="Gonewiththewind";String t;t=s+"one";
    C. String s="Gonewiththewind";String standard=s.toUpperCase(    );
    D. String s="homedirectory";String t=s-"directory".
10.针对下面的程序,那些表达式的值是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;   }   }          (满分:4)
    A. a==b;
    B. a==x;
    C. y==z;
    D. x==y;
    E. a==10.0;
16春学期《JAVA语言程序设计Ⅰ》在线作业3

一、单选题:
1.如果你试图编译下面的代码会发生什么事?Class MyString extends String{}          (满分:3)
    A. 代码编译成功
    B. 代码不能编译,因为没有定义一个main(    )方法
    C. 代码不能编译,因为String是abstract类型的
    D. 代码不能编译,因为String是final类型的
2.下面程序的输出结果是什么? 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); } }          (满分:3)
    A. lava
    B. java
    C. 编译错误
    D. 运行时出现异常
3.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(    ); } }          (满分:3)
    A. t.f;
    B. this.n;
    C. Test.m;
    D. Test.f;
4.下列语句序列执行后,a的值是(    )。int a=13; a%=a/5;          (满分:3)
    A. 3
    B. 13
    C. 1
    D. 169
5.已知如下的命令执行java MyTest a b c请问哪个语句是正确的?          (满分:3)
    A. args = "MyTest a b c"
    B. args = "MyTest"
    C. args = "a"
    D. args= 'b'
6.下面程序的输出结果是什么?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          (满分:3)
    A. 0
    B. 1
    C. 2
    D. 3
7.下列程序的功能是在监控台上每隔一秒钟显示一个字符串“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{          (满分:3)
    A. sleep(1000)InterruptedException
    B. sleep(1000)RuntimeException
    C. Thread.sleep(1000)RuntimeException
    D. Thread.sleep(1000)InterruptedException
8.Person, Student 和Teacher 都是类名。这些类有以下继承关系。Person|--------------------(    )Student    Teacher并且在Java源代码中有如下表达式:Person p = new Student(    );如下哪个语句是正确的?          (满分:3)
    A. 这条语句是合法的
    B. 这条语句是不合法的
    C. 编译时出错
    D. 编译正确但运行时出错
9.下列代码中,将引起一个编译错误的行是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          (满分:3)
    A. 第3行
    B. 第5行
    C. 第6行
    D. 第10行
10.给定下面的类:  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          (满分:3)
    A. good and abc
    B. good and gbc
    C. test ok and abc
    D. test ok and gbc
11.设有下面两个类的定义:classPerson {                         long    id;   // 身份证号   Stringname;   // 姓名    }                                             classStudentextendsPerson {         intscore;// 入学总分         intgetScore(    ){      re          (满分:3)
    A. 包含关系
    B. 继承关系
    C. 关联关系
    D. 无关系,上述类定义有语法错误
12.下面的语句的作用是:(    )。    VectorMyVector = newVector(100,50);          (满分:3)
    A. 创建一个数组类对象MyVector,有100个元素的空间,每个元素的初值为50。
    B. 创建一个向量类对象MyVector,有100个元素的空间,每个元素的初值为50。
    C. 创建一个数组类对象MyVector,有100个元素的空间,若空间使用完时,以50个元素空间单位递增。
    D. 创建一个向量类对象MyVector,有100个元素的空间,若空间使用完时,以50个元素空间单位递增。
13.给出下面的接口:interface A{        int method1(int i);        int method2(int j);}下面那个类实现了这个接口,并且不是抽象的?          (满分:3)
    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){}}
14.选择正确的叙述.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          (满分:3)
    A. 当frame调整大小时,按钮Three和Four 的大小也将调整。
    B. 当frame调整大小时,所有按钮的大小都将调整。
    C. 当frame调整大小时,按钮Two和Four 的大小也将调整。
    D. 当frame调整大小时,按钮One和Two 的大小也将调整。
15.下面的代码段中,执行之后i 和j 的值是什么?int i = 1;int j;j = i++;          (满分:3)
    A. 1
   1
    B. 1
   2
    C. 2
   1
    D. 2
   2
16.设有下面的一个类定义:   classAA {   staticvoidShow(    ){ System.out.println("我喜欢Java!"); }   }   classBB {voidShow(    ){ System.out.println("我喜欢C++!"); } }若已经使用AA类创建对象a和BB类创建对象b,则下面哪一个方法调用是正确的:(    )          (满分:3)
    A. a.Show(    )b.Show(    )
    B. AA.Show(    )BB.Show(    )
    C. AA.Show(    )b.Show(    )
    D. a.Show(    )BB.Show(    )
17.下列程序段执行后t5的结果是(    )。int t1 = 9, t2 = 11, t3=8;int t4,t5;t4 = t1 > t2 ? t1 : t2+ t1;t5 = t4 > t3 ? t4 : t3;          (满分:3)
    A. 8
    B. 20
    C. 11
    D. 9
18.有下面的类:  public class Example{   static int x[]=new int;   public static void main(String args[]){   System.out.println(x);   }   } 下面的那些说法是正确的。          (满分:3)
    A. 编译时出错
    B. 运行时出错
    C. 输出0
    D. 输出null
19.给出下列代码,如何使成员变量m 被方法fun(    )直接访问? class Test { private int m; public static void fun(    ) { ... } }          (满分:3)
    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
20.下面程序的输出结果是什么?public static void main(String args[]){int a=10;int b=20;if(a=b)System.out.println("Not Equal");elseSystem.out.println("Equal");}          (满分:3)
    A. Equal
    B. Not Equal
    C. 编译错误
    D. 运行时将抛出异常
二、多选题:
1.选择所有有效的构造函数。class Happy {}}          (满分:4)
    A. public void Happy(    ){}
    B. public Happy(int c){}
    C. protected Happy(    ){}
    D. public int Happy(    ){}
    E. void Happy(    ){}
2.假定文件名是“Fred.java”,下面哪个是正确的类声明。          (满分:4)
    A. public class Fred{   public int x = 0;   public Fred(int x){   this.x=x;   }   }
    B. public class fred{   public int x = 0;   public Fred(int x){   this.x=x;   }   }
    C. public class Fred extends MyBaseClass{   public int x = 0; }
3.已知如下代码: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 的          (满分:4)
    A. 0
    B. 1
    C. 2
    D. 3
    E. 4
    F. 以上都不是
4.在如下源代码文件Test.java中, 哪个是正确的类定义?          (满分:4)
    A. public class test {public int x = 0;public test(int x) {this.x = x;}}
    B. public class Test{public int x=0;public Test(int x) {this.x = x;}}
    C. public class Test extends T1
   T2 {public int x = 0;public Test(int x) {this.x = x;}}
    D. public class
5.已知如下代码: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)
    A. 5
    B. 4
    C. 6
    D. finished
    E. 什么都不输出
6.已知如下类说明: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(    );// 程序代码…} }如下哪个使用是正确的?          (满分:4)
    A. t.f
    B. this.n
    C. Test.m
    D. Test.n
7.下面代码执行后的输出是什么?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);}          (满分:4)
    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
8.已知如下类定义:class Base {public Base(    ){ //... }public Base( int m ){ //... }protected void fun( int n ){ //... }}public class Child extends Base{// member methods}如下哪句可以正确地加入子类中?          (满分:4)
    A. private void fun( int n ){ //...}
    B. void fun( int n ){ //... }
    C. protected void fun( int n ) { //... }
    D. public void fun( int n ) { //... }
9.你怎样从下面main(    )的调用中访问单词“kiss”?java lyrics a kiss is but a kiss          (满分:4)
    A. args
    B. args
    C. args
    D. args
    E. args
    F. args
10.下面的哪些程序片断可能导致错误。          (满分:4)
    A. String s="Gonewiththewind";String t="good";String k=s+t;
    B. String s="Gonewiththewind";String t;t=s+"one";
    C. String s="Gonewiththewind";String standard=s.toUpperCase(    );
    D. String s="homedirectory";String t=s-"directory".

蓝色麦田 发表于 2016-4-9 12:46:36

无忧答案网太给力了!

蓝色麦田 发表于 2016-4-9 12:47:22

无忧答案网太给力了!
页: [1]
查看完整版本: 东北大学16春学期《JAVA语言程序设计Ⅰ》在线作业参考答案