1.一个字节包含 ____8 位.

2.Which of the following statements is correct?(以下哪个陈述是正确的?)

==【line】行;【statement】语句;【comment】注释;【method】方法==

A.Every line in a program must end with a semicolon(程序中的每一行都必须以分号结尾)

B.Every statement in a program must end with a semicolon(程序中的每个语句都必须以分号结尾)

C.Every comment line must end with a semicolon(每个注释行必须以分号结尾)

D.Every method must end with a semicolon(每个方法都必须以分号结尾)

3.java字节码文件的后缀是.class

4.Java applets_____ can run from a Web browser(Java 小程序_____ 可以从 Web 浏览器运行)

==【applets】小程序==

5.Every statement in Java ends with a semicolon (;)(Java 中的每个语句都以 分号 结尾)

6.Computer can execute the code in ______machine language.(计算机可以在 机器语言 中执行代码。)

7.A compiler translates high-level language program into machine language program(编译器 将高级语言程序翻译成机器语言程序)

==【compiler】编译器==

8.属于解释性程序是___java_____

9.Which JDK command is correct to run a Java application in ByteCode.class?

java ByteCode

(在 ByteCode.class 中运行 Java 应用程序时,哪个 JDK 命令是正确的?)

10.Suppose you define a Java class as follows:

public class Test {

}

In order to compile this program, the source code should be stored in a file named

“假设您按如下方式定义一个 Java 类:
public 类 Test {
}
为了编译此程序,源代码应存储在名为 ”

Test.java

11.Suppose you define a Java class as follows:

class Test {

​ }

In order to compile this program, the source code should be stored in a file named

Any name with extension .java

12.main函数声明正确的是public static void main(String[] args)

13.JDK是(一种程序开发辅助工具 )

14.JDK命令编译Test.java,正确的是?java Test.java

15._____Java virtual machine is a software that interprets Java bytecode(_______Java 虚拟机 是一个解释 Java 字节码的软件)

16.java is Architecture-Neutral(____ 是架构中立的)

17.____Java language specification is a technical definition of the language that includes the syntax and semantics of the Java programming language(____Java 语言规范 是语言的技术定义,包括 Java 编程语言的语法和语义)

18.Java JDK provides an integrated development environment (IDE) for rapidly developing Java programs. Editing, compiling, building, debugging, and online help are integrated in one graphical user interface(____ 为快速开发 Java 程序提供了一个集成开发环境 (IDE)。编辑、编译、构建、调试和在线帮助集成在一个图形用户界面中)

19.Java程序的执行过程中用到一套JDK工具,其中java.exe是指( Java解释器 )

20.Java语言具有许多优点和特点,哪个反映了Java程序并行机制的特点?(多线性

21.下列关于Java语言的特点,描述错误的是( ) Java是面向过程的编程语言

正确的有:Java是跨平台的编程语言、Java支持分布式计算、Java支持多线程

22.在 Java 中,由Java编译器自动导入,而无需在程序中用import导入的包是( java.lang )

23.运行下段代码后,z的结果为??

1
2
3
4
5
6
7
int a = 1, z=0;      

do {

​ ++z;

​ } while(a < 0);

z=1

24.运行下段代码后,x的结果为?

1
2
3
4
5
   int x = 3; 

​ int y = 2;

​ x *= y + 1;

x=9

25.有如下程序段:

1
2
3
4
5
6
7
8
9
10
11
 int total = 0;

​ for ( int i = 0; i < 4; i++ ){

​ if ( i == 1) continue;

​ if ( i == 2) break;

​ total += i;

​ }

则执行完该程序段后total的值为:total=0

26.有关类的说法正确的是? ( )类具有封装性,但可以通过类的公共接口访问类中的数据

27.以下关于构造函数的描述错误的是 构造函数的返回类型只能是void型

正确的有:构造函数是类的一种特殊函数,它的方法名必须与类名相同

构造函数的主要作用是完成对类的对象的初始化工作

一般在创建新对象时,系统会自动调用构造函数

28.下述概念中不属于面向对象方法的是过程调用

29.下面的选项中,哪一项不属于”汽车类”的行为 速度

30.下列说法中,不正确的是( )一个java源程序编译通过后,得到的结果文件数也只有一个

正确的有:一个java源程序经过编译后,得到的文件的扩展名一定是.class

一个java源程序只能有一个public class类定义,且源文件的名字与public class的类名相同,扩展名必须是.java

一个java源程序可以包含多个class类

31.下列说法正确的有( )

constructor在一个对象被new时执行

32.设已声明了一个类A的两个对象a1,a2,为了初始化 a1和a2,下面语句正确的是

a1=new A();a2=new A();

33.若JAVA程序中定义了3个类,编译后可生成(2)个字节码文件.

34.哪个关键字修饰的变量和方法不能从其他类访问?private

35.不是构造函数特点的是( )构造函数带有返回类型

特点有:构造函数与类名相同、构造函数可带参数也可不带、构造函数主要完成对类对象的初始工作

36.哪个关键字声明一个常量?final

37.哪个表达式的结果为0.5?(double) 1 / 2

38.编译Java Application 源程序文件将产生相应的字节码文件,这些字节码文件的扩展名为( .class ).

39.You have a public class called myclass with the main method defined as follows

1
2
3
4
5
   public static void main(String parm[]){

​ System.out.println(parm[0]);

​ }

​ If you attempt to compile the class and run the program as follows

​ java myclass hello

​ What will happen?

“你有一个名为 myclass 的公共类,其 main 方法定义如下

1
2
3
public static void main(String parm[]){
System.out.println(parm[0]);
}

如果您尝试编译该类并按如下方式运行程序
Java MyClass 你好
会发生什么事?

Compilation and output of hello

40.Which specifier essentially declares a variable a global variable?哪个说明符实质上将变量声明为全局变量?

static

41.Which of the following statement prints smith\exam1\test.txt?以下哪项语句打印 smithexam1test.txt?

System.out.println(“smith\exam1\test.txt”);

用双斜杠\、\exam1\、\

42.Which of the following is the correct expression of character 4?以下哪一项是字符 4 的正确表达方式?

‘4’

43.Which of the following is not an advantage of using methods?以下哪项不是使用方法的优势?

Using methods makes program run faster使用方法使程序运行得更快

44.Which of the following can be placed in the blank line in the following code?

1
2
3
4
5
6
7
8
9
10
11
public class <u>Test</u> {

​ private static int id;

​ <u>public static void m1()</u> {

​ ___Test__.id = 45;

​ }

​ }

“以下哪项可以放在以下代码的空行中?Test

45.Which of the following can be placed in the blank line in the following code?

1
2
3
4
5
6
7
8
9
10
11
public class Test {

​ private int id;

​ <u>public void m1()</u> {

​ **this**_____.id = 45;

​ }

​ }

“以下哪项可以放在以下代码的空行中?this

46.Which access specifier allows class members to be accessed by any class in its own package?哪个访问说明符允许类成员由其自己的包中的任何类访问?

==【access】访问==

default

47.What is the value of b after execution?

1
2
3
4
5
6
7
8
9
       int x, b=0; 

​ for(x = 0; x <= 5; ++x){

​ if (x == 2) break;

​ ++b;

​ }

b=2

48.What is the value of b after execution?

1
2
3
4
5
6
7
8
9
            int x, b=0;

​ for(x = 0; x <= 5; ++x){

​ if (x == 2) continue;

​ ++b;

​ }

b=5

49.What is the printout of the following code:

1
2
3
4
5
   double x = 5.5;

​ int y = (int)x;

​ System.out.println("x is " + x + " and y is " + y);

x is 5.5 and y is 5

50.What code may be filled in the blank without causing syntax or runtime errors:

1
2
3
4
5
6
7
8
9
10
11
12
13
   public class Test {

​ java.util.Date date;

​ public static void main(String[] args) {

​ Test test = new Test();

​ System.out.println(_________________);

​ }

​ }

哪些代码可以填空而不会导致语法或运行时错误 test.date

51.To improve readability and maintainability, you should declare ___constants instead of using

​ literal values such as 3.14159.

“为了提高可读性和可维护性,你应该声明 ___constants 而不是使用
文本值,例如 3.14159。

52.To declare a constant MAX_LENGTH inside a method with value 99.98, you write

要在值为 99.98 的方法中声明常量 MAX_LENGTH,您可以编写

final double MAX_LENGTH = 99.98;

53.To add number to sum, you write

sum += number;

54.The default value for data field of a boolean type, numeric type, object type is ___________, respectively

布尔型、数值型、对象型的数据字段默认值分别为 ___________

false, 0, null

55.Test.java程序代码如下:

1
2
3
4
5
1) public class Test{ 
2) ​ public static void main(String[] args){
3) ​ System.out.println(args[1]);
4) ​ }
5) ​ }

​ 以上程序编译后用java Test 2 3 4 5运行的输出结果是什么? ( 3 )

56.System.out.println(“5” + 2);的输出结果应该是 52

57.Suppose x is a char variable with a value ‘b’. What is the printout of the statement

System.out.println(++x)?

c

58.Main()方法的返回类型是:void

59.Java的字符类型采用的是Unicode编码方案,每个Unicode码占用( 16 )个比特位

60.In the program segment below, which line prints?

1
2
3
4
5
6
7
   int x=3, y=5;

​ if (x < y)

​ System.out.println("X= "+x);

​ System.out.println("Y= "+y);

Both

61.How many times will the print statement execute?

1
2
3
4
5
       for (x=0; x<=5; ++x) {

​ System.out.println("X= "+x);

​ --x;}

An infinite number of times

62.Given:

1
2
3
4
5
6
7
8
9
10
11
12
1. public void go() {          
2. String o = "";
3. z:
4. for(int x = 0; x < 3; x++) {
5. for(int y = 0; y < 2; y++) {
6. if(x==1) break;
7. if(x=/=2 && y==1) break z;
8. o = o + x + y;
9. }
10. }
11. System.out.println(o);
12. }

What is the result when the go() method is invoked?

000120

63.Given:

1
2
3
4
5
6
7
1. public class TestString1 {     
2. public static void main(String[] args) {
3. String str = "420";
4. str += 42;
5. System.out.print(str);
6. }
7. }

What is the output?

42042

64.Given:

1
2
3
4
5
6
7
8
9
10
11
12
13
1. public class Test {          
2. public static void main(String [] args) {
3. int x = 5;
4. boolean b1 = true;
5. boolean b2 = false;
6. ​
7. if ((x == 4) && !b2 )
8. System.out.print("1 "); //假
9. System.out.print("2 ");
10. if ((b2 = true) && b1 )
11. System.out.print("3 ");
12. }
13. }

What is the result?

2 3

Analyze the following code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    public class Test {

​ public static void main(String[] args) {

​ double radius;

​ final double PI= 3.15169;

​ double area = radius * radius * PI;

​ System.out.println("Area is " + area);

​ }

​ }

The program has compile errors because the variable radius is not initialized

程序出现编译错误,因为变量 radius 未初始化【A】

66.An object is an instance of a ______class.

对象是________的实例。

67.A variable that is declared inside a method is called a local__ variable

==【variable】变量==

在方法中声明的变量称为________变量

68.__An object represents an entity in the real world that can be distinctly identified.

____对象 表示现实世界中可以明确标识的实体。

69.____The main method is invoked to create an object

调用 ________ 创建对象

70.(double)(5/2)的值为?

2.0

71.To assign a value 1 to variable x, you write

x=1;

  1. 45 / 4的值为?

11

73.在调用方法时,若要使方法改变实参的值,可以用对象作为参数

74.下述哪一组方法,是一个类中方法重载的正确写法? ( )

int addValue( int a, int b ){return a+1;}

​ int addValue ( int b) {return ++b;}

【C】

75.下述哪个说法是不正确的?( )局部变量在使用之前无需初始化,因为有该变量类型的默认值

正确的有:类成员变量由系统自动进行初始化,也无需初始化

参数的作用域就是所在的方法

for语句中定义的变量,当for语句执行完时,该变量就消亡了

76.下面代码中,空白处应填 void__. __

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
public class Test { 
​ public static void main(String[] args) {
​ System.out.print("The grade is ");
​ printGrade(78.5);
​ System.out.print("The grade is ");
​ printGrade(59.5);
​ }
​ public static ______ printGrade(double score) {
​ if (score >= 90.0) {
​ System.out.println('A');
​ }
​ else if (score >= 80.0) {
​ System.out.println('B');
​ }
​ else if (score >= 70.0) {
​ System.out.println('C');
​ }
​ else if (score >= 60.0) {
​ System.out.println('D');
​ }
​ else {
​ System.out.println('F');
​ }
​ }
​ }

77.下列方法头中哪一个不与其他方法形成重载(overload)关系?

int mm()

78.若在某一个类定义中定义有如下的方法:abstract void performDial( );该方法属于

抽象方法

79.面哪个函数是public void aMethod(){…}的重载函数?

public void aMethod ( int m){…}

80.假设A类有如下定义,设a是A类的一个实例,下列语句调用哪个是错误的?A.method1();

​ class A

​ { int i;

​ static String s;

​ void method1() { }

​ static void method2() { }

​ }

正确的有:System.out.println(a.i);

a.method1();

A.method2();

81.You should add the static keyword in the place of ? in Line ________ in the following code:in line 4

​ 1 public class Test {

​ 2 private int age;

​ 3

​ 4 public ? int square(int n) {

​ 5 return n * n;

​ 6 }

​ 7

​ 8 public ? int getAge() {return age;

​ 9 }

​ 10}

82.Which of the following should be defined as a void method?

以下哪项应定义为 void 方法?

Write a method that prints integers from 1 to 100

83.Which of the following are legal declaration and definition of a method

以下哪项是方法的法律声明和定义

void method() {};

84.Which method names follow the JavaBeans standard?

哪些方法名称遵循 JavaBeans 标准?

getCust

85.When you invoke a method with a parameter, the value of the argument is passed to the parameter. This is referred to as _______

使用参数调用方法时,参数的值将传递给参数。这称为 _______pass by value

86.When invoking a method with an object argument, ___________ is passed

当调用带有 object 参数的方法时,the reference of the object_____

87.What will happen if you try to compile and run the following code public class MyClass {

​ public static void main(String arguments[]) {

​ amethod(arguments); }

​ public void amethod(String[] arguments) {

​ System.out.println(arguments);

​ System.out.println(arguments[1]);

​ }}

error Can’t make static reference to void amethod

错误 无法对 void amethod 进行静态引用

88.What is the value of times displayed? 0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public class Test { 
​ public static void main(String[] args) {
​ Count myCount = new Count();
​ int times = 0;
​ for (int i=0; i<100; i++)
​ increment(myCount, times);
​ System.out.println("times = "+ times);
​ }
​ public static void increment(Count c, int times) {
​ c.count++;
​ times++;
​ }
​ }
​ class Count {
​ int count;
​ Count(int c) {
​ count = c;
​ }
​ Count() {
​ count = 1;
​ }
​ }

89.What is the printout of the second println statement in the main method?

f2.i is 1 f2.s is 2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public class Foo {
​ int i;
​ static int s;
​ public static void main(String[] args) {
​ Foo f1 = new Foo();
​ System.out.println("f1.i is " + f1.i + " f1.s is " + f1.s);
​ Foo f2 = new Foo();
​ System.out.println("f2.i is " + f2.i + " f2.s is " + f2.s);
​ }
​ public Foo() {
​ i++;
​ s++;
​ }
​ }

90.The signature of a method consists of ________method name and parameter list

方法的签名由 ________

91.Suppose your method does not return any value, which of the following keywords can be used as a return type?

假设你的方法没有返回任何值,那么以下哪个关键字可以用作返回类型?

void

92.Suppose you wish to provide an accessor method for a boolean property finished, what signature of the method should be?

假设你希望为布尔属性 finished 提供一个访问器方法,该方法的签名应该是什么?

public boolean isFinished()

93.Suppose the xMethod() is invoked from a main method in a class as follows, xMethod() is _________ in the class.

假设 xMethod() 是从类中的 main 方法调用的,如下所示,xMethod() 在类中______a static method___。

​ public static void main(String[] args) {

​ xMethod();

​ }

94.Given:

true true

1
2
3
4
5
6
7
8
9
10
11
12
13
class Fizz { 
​ int x = 5;
​ public static void main(String[] args) {
​ final Fizz f1 = new Fizz();
​ Fizz f2 = new Fizz();
​ Fizz f3 = FizzSwitch(f1,f2);
​ System.out.println((f1 == f3) + " " + (f1.x == f3.x));
​ }
​ static Fizz FizzSwitch(Fizz x, Fizz y) {
​ final Fizz z = x;
​ z.x = 6;
​ return z;
​ } }

​ What is the result?

95.Given:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public class Dark {
int x = 3;
public static void main(String[] args) {
new Dark().go1();
}

void go1() {
int x;
go2(++x);
}

void go2(int y) {
nt x = ++y;
System.out.println(x)
}
}

​ What is the result?

Compilation fails

96.Given:

1
2
3
4
5
6
7
8
9
10
11
12
public class Pass {          
public static void main(String [] args) {
int x = 5;
Pass p = new Pass();
p.doStuff(x);
System.out.print(" main x = " + x);
}

void doStuff(int x) {
System.out.print(" doStuff x = " + x++);
}
}

What is the result?

doStuff x = 5 main x = 5

97.Given:

1
2
3
4
5
6
7
8
9
10
1 public class Frodo extends Hobbit {         
2 public static void main(String[] args) {
3 Short myGold = 7;
4 System.out.println(countGold(myGold, 6));
5 }
6 }

7 class Hobbit {
8 int countGold(int x, int y) { return x + y; }
9 }

​ What is the result?

Compilation fails due to an error on line 4