练习三

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

练习三

第一大题:单选题

1.Java注释方式不包括()。

(A) //…

(B) /* …*/

(C) /** …**/

(D) /** …*/

2. 下列说法正确的是()。

(A) 不需定义类,就能创建对象

(B) 属性可以是简单变量,也可以是一个对象

(C) 属性必须是简单变量

(D) 对象中必有属性和方法

3. 若有定义int x=3,y;则执行语句y=(x++)+(x++)+(x++);后y=()。

(A) 9

(B) 12

(C) 15

(D) 18

4. 编译一个定义了5个类和18个方法的Java源代码文件,编译该源代码文件时会产生几个字节码文件()。

(A)1 (B) 23 (C)18 (D) 5

5. switch(exp)语句中的exp不应是()。

(A) 字符型变量(B) 整型变量(C) 整型常量(D) 逻辑型常量

6. 若有定义如下class dog { float x; static int y;…},则下列说法中正确的是()。

(A) x称为类变量,y为实例变量

(B) x,y均为类变量

(C) x,y均为实例变量

(D) x为实例变量,y为类变量

7. 在Java中下列关于继承的论述中,错误的是()。

(A) 继承具有传递性

(B) 继承关系也称为“即是”(is a)关系

(C) 支持多继承

(D) 继承提高了系统的可重用性

8. 使一个线程进入就绪状态,应调用的方法是()。

(A) init() (B) start() (C) run() (D) sleep()

9. 当服务器的套接字连接建立后,接收客户端的套接字应调用的方法是()。

(A) connect()

(B) accept()

(C) link()

(D) receive()

10. 连接数据库加载JDBC-ODBC桥接驱动器时,可能会发生的异常是()。

(A) FileNotFoundException

(B) ClassNotFoundException

(C) ClassCastException

(D) RuntimeException

11. 将一个RandomAccessFile对象中的文件指针移动到文件中的一个确定位置,应调用方法()。

(A) skipBytes() (B) seek() (C) moveBytes() (D) seekBytes()

12. 对于下列代码:

public class Parent {

public int addValue( int a, int b) {

int s;

s = a+b;

return s;

}

}

class Child extends Parent {

}

下述哪个方法可以加入类Child()。

(A)int addV alue( int x, int y ){// do something...}

(B)public void addV alue (int x, int y ){// do something...}

(C)public int addValue( int x ){// do something...}

(D)public int addValue( int x, int y )throws MyException {//do something...}

13. 看下面一段程序:

class A{

void disp(){

System.out.println("classA");

}

}

class B extends A{

void disp(){

System.out.println("classB");

}

public static void main(String[] args){

A a=new A();

A a1=new B();

a.disp();

a1.disp();

}

}以上程序运行结果是:()。

(A) classA

classA

(B)classB

classB

(C) classA

classB

(D) classB

classA

14. 给出一段程序,试判断哪个是正确的结果()。

public class Test{

public static void throwit(){

System.out.print("throwit ");

throw new RuntimeException();

}

public static void main(String [] aa){

try{

System.out.print("hello ");

throwit();

}catch(Exception re){

System.out.print("caught ");

}finally{

System.out.print("finally ");

}

System.out.print("after ");

}

}

(A)hello throwit caught

(B)hello throwit caught finally after

(C)hello throwit RuntimeException after

(D)hello throwit caught finally after RuntimeException

15. 在Test 类中访问Student类中的member成员之值哪种方式正确?()class Student{

private static int number=1;

public int getnumber(){

return number;

}

相关文档
最新文档