最新消息:可做奥鹏等各院校作业论文,答案请联系QQ/微信:18866732

东大23秋学期《JAVA语言程序设计Ⅰ》在线平时作业【参考答案】

《JAVA语言程序设计Ⅰ》在线平时作业2-00001
试卷总分:100 得分:100
一、单选题 (共 20 道试题,共 60 分)
1.下面的哪些程序段可以正确地获得从命令行传递的参数的个数?
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++;

2.下面程序的输出结果是什么? 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.运行时将抛出异常

3.设有下面两个赋值语句: a = Integer.parseInt(“1024”); b = Integer.valueOf(“1024″).intValue(); 下述说法正确的是( )。
A.a是整数类型变量,b是整数类对象。
B.a是整数类对象,b是整数类型变量。
C.a和b都是整数类对象并且它们的值相等。
D.a和b都是整数类型变量并且它们的值相等。

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; }
A.60
B.54
C.0
D.5

5.下面语句返回的数据类型是什么? (short)10/10.2*2;
A.int
B.double
C.float
D.short

6.下列代码的执行结果是 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();
A.编译错误
B.0
C.1
D.运行成功,但不输出

7.顺序执行下列程序语句后,则b的值是 String a=”Hello”; String b=a.substring(0,2);
A.Hello
B.hello
C.Hel
D.null

8.下面程序的输出结果是什么? 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
A.0
B.1
C.2
D.3

9.如果你有下面的类定义 abstract class Shape{ abstract void draw(); } 请问,在试图编译下面的类定义时会发生什么情况? class Square extends Shape{ }
A.都可以成功编译
B.Shpe可以编译,而Square不能
C.Square可以编译,而Shape不能
D.Shape和Square都不能编译

10.如果你试图编译下面的代码会发生什么事? Class MyString extends String{ }
A.代码编译成功
B.代码不能编译,因为没有定义一个main()方法
C.代码不能编译,因为String是abstract类型的
D.代码不能编译,因为String是final类型的

11.在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奥鹏作业答案请进open5.net或请联系QQ/微信:18866732
B.condition 2
C.condition 3
D.condition 1 finally

12.下列语句序列执行后,k的值是( )。 int j=8, k=15; for( int i=2; i!=j; i++ ) { j-=2; k++; }
A.15
B.16
C.17
D.18

13.下面程序的输出结果是什么? String s= “ABCD”; s.concat(“E”); s.replace(‘C’,’F’); System.out.println(s);
A.编译错误,字符串是不可改变的
B.ABFDE
C.ABCDE
D.ABCD

14.给出下列代码,如何使成员变量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

15.以下由do-while语句构成的循环执行的次数是( )。 int k = 0; do { ++k; }while ( k < 1 );
A.一次也不执行
B.执行1次
C.无限次
D.有语法错,不能执行

16.下列语句序列执行后,a的值是( )。 int a=13; a%=a/5;
A.3
B.13
C.1
D.169

17.设有下面两个类的定义: class Person { long id; // 身份证号 String name; // 姓名 } class Student extends Person { int score; // 入学总分 int getScore(){ re
A.包含关系
B.继承关系
C.关联关系
D.无关系,上述类定义有语法错误

18.下面哪一个类可以访问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.都不能

19.有下面的类:   public class Example{   static int x[]=new int[15];   public static void main(String args[]){   System.out.println(x[5]);   }   } 下面的那些说法是正确的。
A.编译时出错
B.运行时出错
C.输出0
D.输出null

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); } }
A.1
B.2
C.3
D.编译错误

二、多选题 (共 10 道试题,共 40 分)
21.在如下源代码文件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

22.针对下面的程序,那些表达式的值是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;

23.已知如下类定义: 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 ) { //… }

24.已知如下定义: String s = “story”; 下面哪些表达式是合法的?
A.s += “books”;
B.char c = s[1];
C.int len = s.length;
D.String t = s.toLowerCase();

25.已知如下类说明: 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

26.下面代码执行后的输出是什么? 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

27.你怎样从下面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]

28.给出下面的代码段: 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);

29.如果有以下代码,哪几个数字能产生输出 “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

30.请选出创建数组的正确语句。
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];

转载请注明:奥鹏作业之家 » 东大23秋学期《JAVA语言程序设计Ⅰ》在线平时作业【参考答案】

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址