JAVA语言程序设计复习题

  • 格式:doc
  • 大小:155.00 KB
  • 文档页数:30

.

. 一、选择填空题:全部为多选题,只有全部正确才能得分。

1. 编译java程序的命令是___b_____;运行java程序的命令是____a____;产生java文挡的命令是____d____;查询java类型是否是serializable类型的命令是__c______;产生java安全策略文件的命令是____e____;产生类型归档文件.jar的命令是____f____。

A. java B. javac C. serialver

D.javadoc E.policytool F.jar

2. 在一个java原文件中,import, class, package语句的顺序是____f____。

A. import class package

B. class import package

C. package class import

D. import package class

E. class package import

F. package import class

3. 下面叙述正确的有________cde____________。

A. 在一个java原文件中只能定义一个class

B. 在一个java原文件中只能定义一个interface

C. 在一个java原文件中可以定义多个class

D.在一个java原文件中可以定义多个interface

E. 在一个java原文件中可以定义多个class和interface

F. 在一个java原文件中只能定义public class

G. java原文件的前缀一定是所包含类型的名字

4. java程序中程序运行入口方法main的签名正确的有___a_____。

A. public static void main(String args[])

B. static public void main(String[] args)

C. public void static main(String[] args)

D. public void main(String args[])

5. java程序中程序入口方法main的参数代表命令行输入参数,命令行参数从____a____开始。

A. 0 B. 1 C.-1

6. 以下属于正确的java注释有____acd____。

A. //This is comment B. /*This is comment

C. /**This is comment*/ D. /*This is comment*/

7. 以下能作为class, interface, method或variable有效标识符的有______adf__________。

A. For B.boolean C.23age

D. _id E.my name F. $this_is_a_long_variable_name

8. 以下不是java关键字的有___d_____。

A. super C.this D.NULL E.true

9. byte变量的取值范围是___b_____。

A. 0 - 65535 B.-128 ?? 127 C.-256 ?? 255 D.0 - 32767

10. 以下正确的有____ac____。

A. int i = 32; B.float f = 45.32; C. double d=3.2;

11. 根据以下程序选择正确答案___c_____: .

. public class Test {

static int total = 10;

public static void main (String args []) {

new Test();

}

public Test () {

System.out.println("In test");

System.out.println(this);

int temp = this.total;

if (temp > 5) {

System.out.println(temp);

}

}

}

A. 编译出错 B.运行时有异常 C. 编译运行都正确

12. 下面集合定义正确的有____bd____。

A. String strs[] = { ‘a’ ‘b’ ‘c’};

B. String[] strs = {“a”, “b”, “c”};

C. String[] strs = new String{“a” ”b” ”c”};

D.String strs[] = new String[]{“a”, “b”, “c”};

E.String[] strs = new String[3]{“a”, “b”, “c”};

13. 以下switch表达语句正确的有____ac____。

A. public void switchTest(char c){

switch(c){…}

}

B. public void switchTest(long c){

switch(c){…}

}

C. public void switchTest(byte c){

switch(c){…}

}

D. public void switchTest(double c){

switch(c){…}

}

14.面向对象的特性包括___g_____、____i____和____j____。在java中访问权限的限制由严格到宽松依次是____e____、____h____、____b____和___a_____。

A.public B.protected C.identifier

D.data

E.private F.operations G.inheritance

H.default(no modifier)

I.encapsulation J.polymorphism

15. Java方法的参数传递对于基本数据类型如int, byte等,参数传递是____c____;对自定义数据类型,参数传递是___a_____。

A. by reference B.by pointer C. by value D.by address .

. 16. 下面程序出错的有___8,10_____行。

1. class Student{

2. private String name; private int age;

3. public Student(){}

4. public void setName(String name){ =name; }

5. void setAge(int age){ this.age= age; }

6. }

7. public class StudentTest{

8. public void static main(String[] args){

9. Student s = new Student();

10. = “Hellen”;

11. s.setAge(20);

12. }

13. }

17. 方法重载(overloading)必须满足___bce_____。

A. 在不同class中定义的方法 B.在同一类中定义的方法

C. 方法名必须相同 D.返回类型必须相同

E. 参数一定不同 F.参数可以相同

18. 对于构造方法(constructor)描述正确的有___ac_____。

A. 构造方法没有返回类型 B.构造方法一定是public的方法

C.如果我们没有显示定义构造方法,系统会提供一个缺省的

D.构造方法不能重载

19.在java语法中允许___b_____继承,____a____方法不能被继承,______cd__被继承,显示调用父类型的构造方法是通过调用___e_____来完成的。

A. constructor B. single C. methods D. fields E. super

19. 请看以下程序:

class Vehicle {

public void drive() {

System.out.println("Vehicle: drive");

}

}

class Car extends Vehicle {

public void drive() {

System.out.println("Car: drive");

}

}

public class Test {

public static void main (String args []) {

Vehicle v;

Car c;

v = new Vehicle();

c = new Car(); .

. v.drive();

c.drive();

v = c;

v.drive();

}

}

以下描述正确的有___c_____。

A.对于语句v=c;会导致编译错误 B.对于语句v=c;会导致运行错误

C.运行输出:

Vehicle: drive

Car: drive

Car: drive

D.运行输出:

Vehicle: drive

Car: drive

Vehicle: drive

20. 程序:

public class StaticTest {

static {

System.out.println("Hi there");

}

public void print() {