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

所属学校:东北大学 科目:JAVA语言程序设计Ⅰ 2015-03-17 16:23:39
14春学期《JAVA语言程序设计Ⅰ》在线作业3
试卷总分:100 奥鹏学习网(aopeng123.cn) 发布
单选题
多选题
一、单选题(共 20 道试题,共 60 分。)
V
1. 下面程序的输出结果是什么? public static void main(String args[]) { int a=10; int b=20; if(a=b) System.out.println("Not Equal"); else System.out.println("Equal"); }
A. Equal
B. Not Equal
C. 编译错误
D. 运行时将抛出异常
需要购买答案的联系QQ:79691519满分:3 分
2. 下面程序的输出结果是什么? String s= "ABCD"; s.concat("E"); s.replace(C,F); System.out.println(s);
A. 编译错误,字符串是不可改变的
B. ABFDE
C. ABCDE
D. ABCD
此题选: D 满分:3 分
3. 选择正确的叙述. 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
A. 当frame调整大小时,按钮Three和Four 的大小也将调整。
B. 当frame调整大小时,所有按钮的大小都将调整。
C. 当frame调整大小时,按钮Two和Four 的大小也将调整。
D. 当frame调整大小时,按钮One和Two 的大小也将调整。
需要购买答案的联系QQ:79691519满分:3 分
4. 顺序执行下列程序语句后,则b的值是 String a="Hello"; String b=a.substring(0,2);
A. Hello
B. hello
C. Hel
D. null
需要购买答案的联系QQ:79691519满分:3 分
5. 设有下面两个类的定义: class Person { long id; // 身份证号 String name; // 姓名 } class Student extends Person { int score; // 入学总分 int getScore(){ re
A. 包含关系
B. 继承关系
C. 关联关系
D. 无关系,上述类定义有语法错误
需要购买答案的联系QQ:79691519满分:3 分
6. 下列类头定义中,错误的是( )。
A. class x { .... }
B. public x extends y { .... }
C. public class x extends y { .... }
D. class x extends y implements y1 { .... }
需要购买答案的联系QQ:79691519满分:3 分
7. 如果你要读一个参数值,而该参数在 applet 标签内没有定义,则会:
A. 运行时抛出异常
B. 参数值为空
C. 参数值是个空字符串
D.
需要购买答案的联系QQ:79691519满分:3 分
8. 给出下面的接口: 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 分
9. 阅读下列代码后 public class Person{ int arr[]=new int[10]; public static void main(String args[]){ System.out.println(arr[1]); } } 正确的说法是
A. 编译时将产生错误
B. 编译时正确,运行时将产生错误
C. 输出零
D. 输出空
需要购买答案的联系QQ:79691519满分:3 分
10. 设有下面的一个类定义: class AA { static void Show( ){ System.out.println("我喜欢Java!"); } } class BB { void Show( ){ System.out.println("我喜欢C++!"); } } 若已经使用AA类创建对象a和BB类创建对象b,则下面哪一个方法调用是正确的:( )
A. a.Show( ) b.Show( )
B. AA.Show( ) BB.Show( )
C. AA.Show( ) b.Show( )
D. a.Show( ) BB.Show( )
需要购买答案的联系QQ:79691519满分:3 分
11. 设有下面两个赋值语句: a = Integer.parseInt("1024"); b = Integer.valueOf("1024").intValue(); 下述说法正确的是( )。
A. a是整数类型变量,b是整数类对象。
B. a是整数类对象,b是整数类型变量。
C. a和b都是整数类对象并且它们的值相等。
D. a和b都是整数类型变量并且它们的值相等。
此题选: D 满分:3 分
12. 下列哪个选项的java源文件代码片段是不正确的?
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{ }
需要购买答案的联系QQ:79691519满分:3 分
13. 若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 分
14. 设有下面的两个类定义: class AA { void Show(){ System.out.println("我喜欢Java!"); } class BB extends AA { void Show(){ System.out.println("我喜欢C++!"); } 则顺序执行如下语句后输出结果为:( ) AA a; BB b; a.Show(); b.Show();
A. 我喜欢Java! 我喜欢C++!
B. 我喜欢C++! 我喜欢Java!
C. 我喜欢Java! 我喜欢Java!
D. 我喜欢C++! 我喜欢C++!
需要购买答案的联系QQ:79691519满分:3 分
15. 若有循环: int x=5,y=20; do{ y-=x; x++; }while(++x --y);则循环体将被执行( )。
A. 0次
B. 1次
C. 2次
D. 3次
需要购买答案的联系QQ:79691519满分:3 分
16. 以下代码的输出结果是什么? 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); } }
A. 1
B. 2
C. 3
D. 编译错误
需要购买答案的联系QQ:79691519满分:3 分
17. 下面程序运行后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 分
18. 已知如下的命令执行 java MyTest a b c 请问哪个语句是正确的?
A. args[0] = "MyTest a b c"
B. args[0] = "MyTest"
C. args[0] = "a"
D. args[1]= b
需要购买答案的联系QQ:79691519满分:3 分
19. 下面程序的输出结果是什么? 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 ); } }
A. 5 5
B. 5 4
C. 6 4
D. 5 6
此题选: D 满分:3 分
20. 下列程序的功能是在监控台上每隔一秒钟显示一个字符串“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 分
14春学期《JAVA语言程序设计Ⅰ》在线作业3
试卷总分:100 奥鹏学习网(aopeng123.cn) 发布
单选题
多选题
二、多选题(共 10 道试题,共 40 分。)
V
1. 在如下源代码文件Test.java中, 哪个是正确的类定义?
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
需要购买答案的联系QQ:79691519满分:4 分
2. 请选出创建数组的正确语句。
A. float f[][] = new float[6][6];
B. float []f[] = new float[6][6];
C. float f[][] = new float[][6];
D. float [][]f = new float[6][6];
需要购买答案的联系QQ:79691519满分:4 分
3. 已知如下类定义: class Base { public Base (){ //... } public Base ( int m ){ //... } protected void fun( int n ){ //... } } public class Child extends Base{ // member methods } 如下哪句可以正确地加入子类中?
A. private void fun( int n ){ //...}
B. void fun ( int n ){ //... }
C. protected void fun ( int n ) { //... }
D. public void fun ( int n ) { //... }
需要购买答案的联系QQ:79691519满分:4 分
4. 下面的哪些程序片断可能导致错误。
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 分
5. 已知如下类说明: 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.n
需要购买答案的联系QQ:79691519满分:4 分
6. 下面代码执行后的输出是什么? 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 分
7. 针对下面的程序,那些表达式的值是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 分
8. 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 分
9. 如果有以下代码,哪几个数字能产生输出 "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 分
10. 已知如下定义: String s = "story"; 下面哪些表达式是合法的?
A. s += "books";
B. char c = s[1];
C. int len = s.length;
D. String t = s.toLowerCase();
需要购买答案的联系QQ:79691519满分:4 分
版权声明

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

分享: