快捷导航
帮助中心知识拓展客服QQ 515224986
扫码加微信
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[10];  public static void main(String args[]){  System.out.println(arr[1]);  }  }  正确的说法是          (满分: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[count]!=null) count++;
    D. int count=0;while(!(args[count].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[15];   public static void main(String args[]){   System.out.println(x[5]);   }   } 下面的那些说法是正确的。          (满分: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[6][6];
    B. float []f[] = new float[6][6];
    C. float f[][] = new float[][6];
    D. float [][]f = new float[6][6];
4.你怎样从下面main(    )的调用中访问单词“kiss”?java lyrics a kiss is but a kiss          (满分:4)
    A. args[0]
    B. args[1]
    C. args[2]
    D. args[3]
    E. args[4]
    F. args[5]
5.已知如下定义:String s = "story";下面哪些表达式是合法的?          (满分:4)
    A. s += "books";
    B. char c = s[1];
    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[3]=”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

奥鹏易百网www.openhelp100.com专业提供网络教育各高校作业资源。

共 0 个关于本帖的回复 最后回复于 2016-3-30 21:12

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

精彩推荐

    明星用户

    QQ|Archiver|手机版|小黑屋|www.openhelp100.com ( 冀ICP备19026749号-1 )

    GMT+8, 2024-4-19 15:30