|
电科17春《JAVA程序设计》在线作业1
一、单选题:
1.布局管理器使容器中各个构件呈网格布局,平均占据容器空间。 (满分:4)
A. CardLayout
B. BorderLayout
C. FlowLayout
D. GridLayout
2.public class Test{ public static void main(String[] args){ String a=args[1];String b=args[2];String c=args[3]; } }execute command:java Test Red Green Bluewhat is the value of c? (满分:4)
A. c has value of null
B. c has value of Blue
C. the code does not compile
D. the program throw an exception
3.自定义的异常类可以从下列 类继承。 (满分:4)
A. Error类
B. AWTError
C. VirtualMachineError
D. Exception及其子类
4.已知如下代码:public?class?Test{ static long?a[]?=?new?long[10]; public?static?void?main?(?String?arg[]?)?{System.out.println?(?a[6]?); }}则下面 个语句是正确的。 (满分:4)
A. Output is null.
B. When compile
some error will occur.
C. Output is 0.
D. When running
some error will occur.
5.向容器添加新构件的方法是 (满分:4)
A. add( )
B. insert( )
C. hill( )
D. set( )
6.已知如下的命令执行: java MyTest aa bb cc则下面 个语句是正确的。 (满分:4)
A. args[0] = "MyTest aa bb cc"
B. args[0] = "MyTest"
C. args[0] = "aa"
D. args[1]="aa"
7.构造方法在 时候被调用。 (满分:4)
A. 类定义时
B. 创建对象时
C. 调用对象方法时
D. 使用对象的变量时
8.下面是类A的构造函数声明,其中正确的是 (满分:4)
A. void A(int x){...}
B. A(int x){...}
C. a(int x){...}
D. void a(int x){...}
9.下列关于接口的叙述中, 是正确的。 (满分:4)
A. 接口与抽象类是相同的概念
B. 接口之间不能有继承关系
C. 一个类只能实现一个接口
D. 接口中只含有抽象方法和常量
10.类是所有异常类的父类。 (满分:4)
A. Throwable
B. Error
C. Exception
D. AWTError
11.给出下面的代码段: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){ //?assignment?x=a,?y=bw=d;z=c; }}在代码说明//?assignment?x=a,?y=b处写入如下 个代码是正确的。 (满分:4)
A. Base(a
b);
B. x=a
y=b;
C. super(a
b);
D. this(a
b);
12.设有下面的两个类定义:class A{void who( ){System.out.print("A");}}class B extends A{void who( ){System.out.print("B");}}则顺序执行如下语句后输出的结果为 。A a=new B( );B b=new B( );a.who( );b.who( ); (满分:4)
A. AA
B. AB
C. BB
D. BA
13.如下 方法可以将MenuBar加入Frame中。 (满分:4)
A. setMenu( )
B. setMenuBar( )
C. add( )
D. addMenuBar( )
14.下面 语句是创建数组的正确语句。 (满分:4)
A. float f[5][6] = new float[5][6];
B. float []f[] = new float[5][6];
C. float f[5][] = new float[][6];
D. float [5][]f = new float[5][6];
15.Java语言中,字符变量以char类型表示,它在内存中占 位bit。 (满分:4)
A. 8
B. 16
C. 32
D. 2
16.已知如下代码:public?class?Test{ static long?a[]?=?new?long[10]; public?static?void?main?(?String?arg[]?)?{System.out.println?(?a[6]?); }}则下面 个语句是正确的。 (满分:4)
A. Output is null.
B. When compile
some error will occur.
C. Output is 0.
D. When running
some error will occur.
17.下列叙述中正确的是 (满分:4)
A. Java是不区分英文字母大小写的,源文件名与程序类名不允许相同
B. Java语言以方法为程序的基本单位
C. Applet是Java的一类特殊应用程序,它嵌入HTML中,随主页发布到互联网上
D. 以//符开始的为多行注释语句
18.当方法遇到异常又不知如何处理时,应该 (满分:4)
A. 捕获异常
B. 抛出异常
C. 用throws声明异常
D. 嵌套异常
19.下列 是异常的含义。 (满分:4)
A. 程序的语法错
B. 程序编译或运行中所发生的异常事件
C. 程序预先定义好的异常事件
D. 程序编译错误
20.给出下面的代码段: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){ //?assignment?x=a,?y=bw=d;z=c; }}在代码说明//?assignment?x=a,?y=b处写入如下 个代码是正确的。 (满分:4)
A. Base(a
b);
B. x=a
y=b;
C. super(a
b);
D. this(a
b);
三、判断题:
1.( )Java的各种数据类型占用固定长度,与具体的软硬件平台环境无关。 (满分:4)
A. 错误
B. 正确
2.( )A class can implement as many interfaces as needed. (满分:4)
A. 错误
B. 正确
3.( )用“+”可以实现字符串的拼接,用“-”可以从一个字符串中去除一个字符子串。 (满分:4)
A. 错误
B. 正确
4.( )A subclass inherits all methods( including the constructor ) from the superclass. (满分:4)
A. 错误
B. 正确
5.( )Java程序里,创建新的类对象用关键字new,回收无用的类对象使用关键字free。 (满分:4)
A. 错误
B. 正确
|
|