在线作业 发表于 2017-5-14 11:25:30

电子科技大17春《面向对象程序设计》在线作业答案

电子科技大17春《面向对象程序设计》在线作业1

一、单选题:
1.Java语言的许多特点中,下列         特点是C++语言所不具备的。          (满分:4)
    A. 高性能
    B. 跨平台
    C. 面向对象
    D. 有类库
2.下面是类A的构造函数声明,其中正确的是          (满分:4)
    A. void A(int x){...}
    B. A(int x){...}
    C. a(int x){...}
    D. void a(int x){...}
3.下面         语句是创建数组的正确语句。          (满分:4)
    A. float f = new float;
    B. float []f[] = new float;
    C. float f[] = new float[];
    D. float []f = new float;
4.向容器添加新构件的方法是          (满分:4)
    A. add(    )
    B. insert(    )
    C. hill(    )
    D. set(    )
5.如下             方法可以将MenuBar加入Frame中。          (满分:4)
    A. setMenu(    )
    B. setMenuBar(    )
    C. add(    )
    D. addMenuBar(    )
6.对于catch子句的排列,下列         是正确的。          (满分:4)
    A. 父类在先,子类在后
    B. 子类在先,父类在后
    C. 有继承关系的异常不能在同一个try结构程序段内
    D. 排列顺序可任意
7.下列关于接口的叙述中,         是正确的。          (满分:4)
    A. 接口与抽象类是相同的概念
    B. 接口之间不能有继承关系
    C. 一个类只能实现一个接口
    D. 接口中只含有抽象方法和常量
8.下列关于继承的叙述中,         是正确的。          (满分:4)
    A. 子类能继承父类的所有方法和状态
    B. 子类能继承父类的非私有方法和状态
    C. 子类只能继承父类的public方法和状态
    D. 子类只能继承父类的方法,而不继承状态
9.类是所有异常类的父类。          (满分:4)
    A. Throwable
    B. Error
    C. Exception
    D. AWTError
10.当方法遇到异常又不知如何处理时,应该          (满分:4)
    A. 捕获异常
    B. 抛出异常
    C. 用throws声明异常
    D. 嵌套异常
11.已知如下代码:public?class?Test{static long?a[]?=?new?long;public?static?void?main?(?String?arg[]?)?{System.out.println?(?a?);}}则下面         个语句是正确的。          (满分:4)
    A. Output is null.
    B. When compile, some error will occur.
    C. Output is 0.
    D. When running, some error will occur.
12.如下      字符串是Java中合法的用户自定义标识符。          (满分:4)
    A. super
    B. 3number
    C. #number
    D. $number
13.以下         约束符可用于定义成员常量。          (满分:4)
    A. static
    B. final
    C. abstract
    D. No modifier can be used
14.给出下面的代码段: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);
15.监听器接口的方法返回值是          (满分:4)
    A. int
    B. String
    C. void
    D. Object
16.public class Test{      public static void main(String[] args){      String a=args;String b=args;String c=args;      }    }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
17.若要抛出异常,应该使用下列         子句。          (满分:4)
    A. catch
    B. throw
    C. try
    D. finally
18.Java语言中,字符变量以char类型表示,它在内存中占         位bit。          (满分:4)
    A. 8
    B. 16
    C. 32
    D. 2
19.给出下面的代码段: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);
20.下列叙述中,         是正确的。          (满分:4)
    A. 类是变量和方法的集合体
    B. 数组是无序数据的集合
    C. 抽象类可以实例化
    D. 类成员数据必须是公有的
三、判断题:
1.(    )Java程序里,创建新的类对象用关键字new,回收无用的类对象使用关键字free。          (满分:4)
    A. 错误
    B. 正确
2.(    )A class can implement as many interfaces as needed.          (满分:4)
    A. 错误
    B. 正确
3.(    )A subclass inherits all methods( including the constructor ) from the superclass.          (满分:4)
    A. 错误
    B. 正确
4.(    )Java的各种数据类型占用固定长度,与具体的软硬件平台环境无关。          (满分:4)
    A. 错误
    B. 正确
5.(    )用“+”可以实现字符串的拼接,用“-”可以从一个字符串中去除一个字符子串。          (满分:4)
    A. 错误
    B. 正确
17春《面向对象程序设计》在线作业2

一、单选题:
1.1main方法是Java Application程序执行的入口点,下列         main方法原型是不正确的。          (满分:4)
    A. public static void main(String[]args)
    B. public static void main(String args[])
    C. public static void main(String[]a)
    D. public static void main(string[]args)
2.在Java中,         语句作为异常处理的统一出口。          (满分:4)
    A. throw
    B. try
    C. finally
    D. catch
3.若在某一个类定义中定义有方法:abstract void f(    );则该类是          (满分:4)
    A. public类
    B. final类
    C. 抽象类
    D. 不能确定
4.在Java中,用         关键字定义常量。          (满分:4)
    A. define
    B. fixed
    C. const
    D. final
5.A class design requires that a member variable should be accessible only by same package, which modifer word should be used?          (满分:4)
    A. protected
    B. public
    C. no modifer
    D. private
6.Applet运行时,被浏览器或appletviewer调用的第一个方法是          (满分:4)
    A. paint(    )
    B. init(    )
    C. start(    )
    D. destroy(    )
7.在一个applet标记中,         标记属性项可以省去不写。          (满分:4)
    A. code
    B. codebase
    C. width
    D. height
8.一个Java Application运行后,在系统中是作为一个          (满分:4)
    A. 线程
    B. 进程
    C. 进程或线程
    D. 不可预知
9.下列类定义中不正确的是          (满分:4)
    A. public class A extends B{}
    B. public class A extends B,D{}
    C. public class A implements B,D{}
    D. public class A extends B implements C,D,E{}
10.在Applet生命周期中,下列         方法是在装载Applet时被调用。          (满分:4)
    A. stop(    )
    B. init(    )
    C. start(    )
    D. destroy(    )
11.实现下列         接口可以对TextField对象的事件进行监听和处理。          (满分:4)
    A. ActionListener
    B. FocusListener
    C. MouseMotionListener
    D. WindowListener
12.计算机中的流是          (满分:4)
    A. 流动的字节
    B. 流动的对象
    C. 流动的文件
    D. 流动的数据缓冲区
13.在Java中,子类重新定义一个与从父类那里继承来的域变量(成员变量)完全相同的变量,这称为域的          (满分:4)
    A. 隐藏
    B. 覆盖
    C. 重载
    D. Java不支持此特性
14.Which modifer should be applied to a declaration of a class member variable for the value of variable to remain constant after the creation of the object?          (满分:4)
    A. static
    B. final
    C. const
    D. abstract
15.每个使用Swing构件的程序必须有一个          (满分:4)
    A. 按钮
    B. 标签
    C. 菜单
    D. 容器
16.What happens when you try to compile and run the following program?          class Mystery{String s;public static void main(String[] args){Mystery m=new Mystery(    );m.go(    );}void Mystery(    ){s="constructor";}void go(    ){System.out.println(s);}}          (满分:4)
    A. this code will not compile
    B. this code compliles but throws an exception at runtime
    C. this code runs and "constructor" in the standard output
    D. this code runs and writes "null" in the standard output
17.Give the following java source fragement://point xpublic class Interesting{//do something}Which statement is correctly Java syntax at point x?          (满分:4)
    A. import java.awt.*;
    B. package mypackage
    C. static int PI=3.14
    D. public class MyClass{//do other thing…}
18.下列语句输出结果为         。public class A{public static void main(String[]args){byte b=0xa;System.out.println(b);}}          (满分:4)
    A. 0xa
    B. a
    C. 1
    D. 10
19.下列叙述错误的是          (满分:4)
    A. Java是一种面向对象的网络编程语言
    B. Java Applet程序在网络上传输不受硬软件平台的限制
    C. Java提供了类库支持TCP/IP协议
    D. Java语言允许使用指针访问内存
20.What happens when you try to compile and run the following program?          class Mystery{String s;public static void main(String[] args){Mystery m=new Mystery(    );m.go(    );}void Mystery(    ){s="constructor";}void go(    ){System.out.println(s);}}          (满分:4)
    A. this code will not compile
    B. this code compliles but throws an exception at runtime
    C. this code runs and "constructor" in the standard output
    D. this code runs and writes "null" in the standard output
三、判断题:
1.(    )Java语言没有无符号整数类型、指针类型、结构类型、枚举类型、共用体类型。          (满分:4)
    A. 错误
    B. 正确
2.(    )有的类定义时可以不定义构造函数,所以构造函数不是必需的。          (满分:4)
    A. 错误
    B. 正确
3.(    )在Java语言中,系统常量null,false,true既可以大写,也可以小写。          (满分:4)
    A. 错误
    B. 正确
4.(    )如果p是父类Parent的对象,而c是子类Child的对象,则语句c = p是正确的。          (满分:4)
    A. 错误
    B. 正确
5.(    )子类要调用父类的方法,必须使用super关键字。          (满分:4)
    A. 错误
    B. 正确
17春《面向对象程序设计》在线作业3

一、单选题:
1.下列         是Java的调试器,如果编译器返回程序代码的错误,可以用它对程序进行调试。          (满分:4)
    A. java.exe
    B. javadoc.exe
    C. jdb.exe
    D. javaprof.exe
2.设有下面的两个类定义:class A{void show(    ){System.out.print("AA");}}class B extends A{void show(    ){System.out.print("BB");}}则顺序执行如下语句后输出的结果为         。A a=new A(    );B b=new B(    );a.show(    );b.show(    );          (满分:4)
    A. AAAA
    B. AABB
    C. BBBB
    D. BBAA
3.设有下面的两个类定义:class A{void show(    ){System.out.print("AA");}}class B extends A{void show(    ){System.out.print("BB");}}则顺序执行如下语句后输出的结果为         。A a=new A(    );B b=new B(    );a.show(    );b.show(    );          (满分:4)
    A. AAAA
    B. AABB
    C. BBBB
    D. BBAA
4.创建字符串s:String s=new String("abcd");以下         将改变s。          (满分:4)
    A. s.append("x");
    B. s.concat("y");
    C. s.substring(3);
    D. 以上语句都不会
5.class A{public String toString(    ){return 4+"";}}class B extends A{public String toString(    ){return super.toString(    )+3;}}public class Test{public static void main(String[]args)   {B b=new B(    );System.out.println(b.toString(    ));}}what is the result?          (满分:4)
    A. 7
    B. null
    C. the program throw an exception
    D. 43
6.class A{public int getNumber(int a){return a+1;}}class B extends A{public int getNumber(int a, char c){return a+2;} public static void main(String[] args)   {B b=new B(    );System.out.println(b.getNumber(0));} }what is the result?          (满分:4)
    A. compilation succeeds and 1 is printed
    B. compilation succeeds and 2 is printed
    C. compilation succeeds and 3 is printed
    D. An error at this program cause compilation to fail
7.Which statement is correctly declare a variable a which is suitable for refering to an array of 50 string empty object?          (满分:4)
    A. String [] a;
    B. char a[][];
    C. String a;
    D. String a;
8.下列代码的执行结果是         。public class A{public static void main(String[]args){System.out.println(5/2);}}          (满分:4)
    A. 2.5
    B. 2.0
    C. 3
    D. 2
9.关键字super的作用是          (满分:4)
    A. 用来访问父类被隐藏的成员变量
    B. 用来调用父类中被重载的方法
    C. 用来调用父类的构造方法
    D. 以上都是
10.对于构造方法,下列叙述正确的是          (满分:4)
    A. 构造方法的方法名必须与类名相同
    B. 构造方法必须用void申明返回类型
    C. 构造方法可以被程序调用
    D. 若编程人员没在类中定义构造方法,程序将报错
11.有类定义:abstract class A{public abstract void f(    );}下面关于该类的描述中正确的是          (满分:4)
    A. 该类可以用new A(    );实例化一个对象
    B. 该类不能被继承
    C. 该类的方法不能被重载
    D. 以上说法都不对
12.Java语言是在         语言基础上衍生的。          (满分:4)
    A. pascal
    B. C
    C. C++
    D. VF
13.Which modifier should be applied to a method for the lock of object "this" to be obtained prior to excution any of the method body?          (满分:4)
    A. synchronized
    B. abstract
    C. final
    D. static
14.有数组定义:int a[]={0,1,2,3,4,5,6};,则a数组的数组元素个数为          (满分:4)
    A. a.length(    )
    B. a.length(    )+1
    C. a.length
    D. a.length+1
15.Give incompleted method://one{if(unsafe(    )){//do something…}else if(safe(    )){//do the other…}}The method unsafe(    ) will throw an IOException, which completes the method of declaration when added at line one?          (满分:4)
    A. public IOException methodName(    )
    B. public void methodName(    )
    C. public void methodName(    ) throw IOException
    D. public void methodName(    ) throws IOException
16.下列保留字中书写正确的是          (满分:4)
    A. Case
    B. For
    C. try
    D. viod
17.在j2sdk1.4.2版中,解压得到的目录中,         是存放编译器、解释器和其他许多工具的目录。          (满分:4)
    A. jre
    B. lib
    C. demo
    D. bin
18.在使用interface声明一个接口时,只可以使用         修饰符修饰该接口。          (满分:4)
    A. public
    B. protected
    C. private和protected
    D. private
19.在Java的基本数据类型中,int型数据占用         字节内存空间。          (满分:4)
    A. 1
    B. 2
    C. 4
    D. 不能确定,取决于计算机字长
20.class A{public int getNumber(int a){return a+1;}}class B extends A{public int getNumber(int a, char c){return a+2;} public static void main(String[] args)   {B b=new B(    );System.out.println(b.getNumber(0));} }what is the result?          (满分:4)
    A. compilation succeeds and 1 is printed
    B. compilation succeeds and 2 is printed
    C. compilation succeeds and 3 is printed
    D. An error at this program cause compilation to fail
三、判断题:
1.(    )字符串分为两大类,一类是字符串常量,使用StringBuffer类的对象表示;另一类是字符串变量,使用String类的对象表示。          (满分:4)
    A. 错误
    B. 正确
2.(    )抽象方法必须在抽象类中,所以抽象类中的方法都必须是抽象方法。          (满分:4)
    A. 错误
    B. 正确
3.(    )J2SDK中主要有两个相关环境变量,即path和classpath。前者指定了JDK命令搜索路径,后者指定了Java类路径。          (满分:4)
    A. 错误
    B. 正确
4.(    )Java的屏幕坐标是以像素为单位,容器的左下角被确定为坐标的起点。          (满分:4)
    A. 错误
    B. 正确
5.(    )final类中的属性和方法都必须被final修饰符修饰。          (满分:4)
    A. 错误
    B. 正确

jinlimin1 发表于 2017-5-17 14:18:17

在做作业,求解题参考资料。
页: [1]
查看完整版本: 电子科技大17春《面向对象程序设计》在线作业答案