奥鹏易百

 找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

帮助中心知识拓展客服QQ 515224986
查看: 416|回复: 0

[东北大学] 《JAVA语言程序设计Ⅰ》2.如果你有下面的类定义abstract class...

[复制链接]

2万

主题

27

回帖

6万

积分

管理员

积分
60146
发表于 2017-4-7 21:19:13 | 显示全部楼层 |阅读模式
扫码加微信
东大17春学期《JAVA语言程序设计Ⅰ》在线作业2
一、单选题:
1.下面哪一个类可以访问foo包中的所有变量?package foo;class a{int c}class b{private int d}class c{public int e}          (满分:3)
    A. class a
    B. class b
    C. class c
    D. 都不能
2.如果你有下面的类定义abstract class Shape{  abstract void draw(    );}请问,在试图编译下面的类定义时会发生什么情况?class Square extends Shape{}          (满分:3)
    A. 都可以成功编译
    B. Shpe可以编译,而Square不能
    C. Square可以编译,而Shape不能
    D. Shape和Square都不能编译
3.如果你试图编译下面的代码会发生什么事?Class MyString extends String{}          (满分:3)
    A. 代码编译成功
    B. 代码不能编译,因为没有定义一个main(    )方法
    C. 代码不能编译,因为String是abstract类型的
    D. 代码不能编译,因为String是final类型的
4.有下面的类:  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
5.下列语句序列执行后,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
6.给定下面的类:  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
7.若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
8.下列代码的执行结果是 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. 运行成功,但不输出
9.若有循环:int x=5,y=20;do{    y-=x;     x++;  }while(++x<--y);则循环体将被执行(    )。          (满分:3)
    A. 0次
    B. 1次
    C. 2次
    D. 3次
10.下面程序的输出结果是什么?String s= "ABCD";s.concat("E");s.replace('C','F');System.out.println(s);          (满分:3)
    A. 编译错误,字符串是不可改变的
    B. ABFDE
    C. ABCDE
    D. ABCD
11.有下面的类:  public class Example{   public static void main(String args[]){   static int x[] = new int[15];   System.out.println(x[5]);   }   }下面的那些说法是正确的。          (满分:3)
    A. 编译时出错
    B. 运行时出错
    C. 输出0
    D. 输出null
12.下面程序的输出结果是什么? 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. 运行时出现异常
13.下面程序运行后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
14.下列语句序列执行后,a的值是(    )。int a=13; a%=a/5;          (满分:3)
    A. 3
    B. 13
    C. 1
    D. 169
15.下面的哪些程序段可以正确地获得从命令行传递的参数的个数?          (满分: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++;
16.下列哪个选项的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{ }
17.下列代码中,将引起一个编译错误的行是  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行
18.在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");          (满分:3)
    A. condition 1
    B. condition 2
    C. condition 3
    D. condition 1finally
19.选择正确的叙述.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 的大小也将调整。
20.已知如下代码:boolean m = true;if( m = false )System.out.println("False");elseSystem.out.println("True");执行结果是什么?          (满分:3)
    A. False
    B. True
    C. 编译时出错
    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.请选出创建数组的正确语句。          (满分: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];
3.在如下源代码文件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
4.下面代码执行后的输出是什么?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
5.假定文件名是“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; }
6.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;
7.选择所有有效的构造函数。class Happy {}}          (满分:4)
    A. public void Happy(    ){}
    B. public Happy(int c){}
    C. protected Happy(    ){}
    D. public int Happy(    ){}
    E. void Happy(    ){}
8.如果有以下代码,哪几个数字能产生输出 "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
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=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);
10.已知如下代码: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. 以上都不是

奥鹏易百网www.openhelp100.com专业提供网络教育各高校作业资源。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-5-19 16:00

Powered by openhelp100 X3.5

Copyright © 2001-2024 5u.studio.

快速回复 返回顶部 返回列表