background image

实习生 JAVA BS 软件开发工程师招聘试题

考试时间:60

    

分钟

请将答案写在白纸上

一、单选题(共 10 题,每题 分)

1.

对象 b

  

最早在以下哪个选项前被垃圾回收?( )

public class Q76a9 { 

static String f() { 

String a = "hello"; 
String b = "bye";                     
String c = b + "!";                     // line A 
String d = b; 
b = a;                               // line B
d = a;                               // line C
return c;                             // line D


public static void main(String args[]) { 

String msg = f(); 
System.out.println(msg);             

(A)line A

(B)line B

(C)line C

(D)line D

2.

 

下面程序段没有错误的是 (  )

(A)int x = 1; 

while (x <= 10) ;

x++;

(B)for ( int y = 1; y != 10; y++) {

System.out.println(y / 10);

}

(C)switch (n) {

case 1:
System.out.println(“The number is 1”);
case 2:
System.out.println(“The number is 2”);
break;
default:
System.out.println(“The number is not 1 or 2”);
break;

  }

(D)打印 1 到 10 的值

int n = 0;

第 1 页 /  

共 4 页