Java考试资料(考试试卷二)

  • 格式:doc
  • 大小:59.65 KB
  • 文档页数:6

第 1 页 共 6 页 装订线内不要答题,装订线外不要写姓名、学号、学院专业年级班签个人信息,违者试卷作0分处理 考 点 号

教 室 号

姓 名

学 院

专 业

年 级

班 号

学号(全号) 湖南农业大学课程考核试卷

课程名称(全称):Java程序设计(双语) 课程代码:20638B0

考核时间:2011 年01月 04 日 试卷号: B

考核对象:电子商务08-1、电子商务08-2

大题号 一 二 三 四 五 六 七 八 九 十 总分

题分 20 20 20 10 10 20

得分

1. Which of the following are Java modifiers? ( )

A. public B. true C. friendly D. transient

2. Choose the valid identifier from those listed below. ( )

A. MyMethod B. 3byte C. 5_const D.true

3. ( ) is a set of primitive instructions built into every computer?

A. The machine language

B. Assembly language

C. The low-level language

D. The high-level language

4. What is the return value of the main() method in Java? ( )

A. String B. int C. char D. void

5. Which is not valid Java keyword? ( )

A. const B. NULL C. false D. this

6. Which of the following assignments is NOT legal? ( )

A.float a = 2.0 B.double b = 2.0 C.int c = 2 D.long d = 2

7. Which is not a high-level language? ( )

A. c language B. BASIC language

C. Visual BASIC language D. Assembly language

8. Given the following code:

switch (m){

case 0: System.out.println(Condition 0); 得分 I、Choose one correct answer(Total 20 points,each question 2

points)

第 2 页 共 6 页 case 1: System.out.println(Condition 1);

case 2: System.out.println(Condition 2);

case 3: System.out.println(Condition 3);break;

default: System.out.println(Other Condition);

}

Which values of m will cause Condition 2 is output? ( )

A. 0,1 and 2 B. only 1 C. 3 D. 4

9. Which modifier is NOT legal in Java? ( )

A. private B. public C. protected D. protect

10. There are three editions of the Java API except ( )

A. J2SE B. J2EE C. J2ME D. J2NE

1、√Java is a kind of Object-oriented programming language.(√ )

2、basic is a high-level language.(√ )

3、A local variable must be declared before it can be used.(√)

4、The solution of overloading methods is to create another method

with the same name but different parameters.(√)

5、compilation errors occur when a program does not perform the way

it was intended to.( X)

6、You can declare a local variable with the same multiple times in

different non-nesting blocks in a method.( √ )

7、“==” and “euqals()” are the same.(√)

8、break immediately ends the innermost loop that contain it.(√)

9、Letter A and letter a are the same in Java.(X)

10、You can use the keyword „new‟ to create an instance object of a

class.( √ )

1.Public class TestMax{

public static void main(String[] args){

int i=5; 得分 II、Decide correct or wrong(Total 20 points,each question

2 points, “√”means right, “X” means wrong)

得分 III、Fill the following blanks(Total 20 points,each blank 2

points)

第 3 页 共 6 页 int j=2;

int k=max(i,j)

System.out.println(“The maximum between ” + i + “and “ + j +”is ” + k);

}

public static int max (int num1, int num2) {

int result;

if (num1 > num2)

result = num1 ;

else

result = num2 ;

return result ;

}

}

2.switch(m){

case 0: System.out.println("case 0! ");

case 1: System.out.println("case 1! "); break;

default: System.out.println("default!");

}

(1)when m=0 , the result is: case 0! case 1!.

(2)when m=1, the result is: case 1! .

(3)when m=3, the result is: default! .

1.

int i=0;

while (i < =10)

{

i++;

}

System.out.println("i is " + i); 得分 IV、Write the results after code is executed.(Total 10 points,each question 5 points)

第 4 页 共 6 页

The result of question 1 is : i is 11

2.

public class TestpassByValue {

public static void main ( String[] args) {

int num1=1;

int num2=2;

swap(num1,num2);

System.out.println(num1,num2)

}

public static void swap(int n1, int n2) {

int temp=1;

n1=n2;

n2=temp;

}

The result of question 2 is : 1 2

1. Answer the characteristics of Java briefly.

2. Answer the rule of evaluating an expression.

得分 V、answer questions briefly(Total 10 points,each question 5

points)