中兴面试测试题 下载本文

内容发布更新时间 : 2024/10/21 23:14:55星期一 下面是文章的全部内容请认真阅读。

面试测试题2 (一)、选择题(4′×10):

(1)Which of the following range of short is correct? C

A. -27 ~ 27-1 B. 0 ~ 216-1 C. -215 ~ 215-1 D. -231 ~ 231-1 (2)Which declarations of identifiers are legal? ABE

A. $persons B. TwoUsers C. *point D. this E. _endline (3)Given the following code: C 1:public void modify() { 2: int i, j, k; 3: i = 100;

4: while ( i > 0 ) { 5: j = i * 2;

6: System.out.println (\ 7: k = k + 1; 8: i--; 9: } 10:}

Which line might cause an error during compilation? C A. line 4 B. line 6 C. line 7 D. line 8

(4)Which of the following answer is correct to express the value 8 in octal number? A A. 010 B. 0x10 C. 08 D. 0x8 (5)Which are not Java keywords?AB

A. TRUE B. sizeof C. const D. super E. void (6)Given the following code: 1:class Person {

2: public void printValue(int i, int j) {//... } 3: public void printValue(int i){//... } 4:}

5:public class Teacher extends Person { 6: public void printValue() {//... } 7: public void printValue(int i) {//...} 8: public static void main(String args[]){ 9: Person t = new Teacher(); 10: t.printValue(10); 11: } 12:}

Which method will the statement on line 10 call? D

A. on line 2 B. on line 3 C. on line 6 D. on line 7 (7)Given the following code: public void test() {

try { oneMethod();

System.out.println(\

} catch (ArrayIndexOutOfBoundsException e) { System.out.println(\

} catch(Exception e) {

System.out.println(\ } finally {

System.out.println(\ } }

Which will display if oneMethod run normally? AD

A. condition 1 B. condition 2 C. condition 3 D. finally (8)Given the following code: public class Test {

void printValue(int m){

do { System.out.println(\ }

while( --m > 10 ); }

public static void main(String arg[]) { int i=10;

Test t= new Test(); t.printValue(i); } }

Which will be output? C A. The value is 8 B. The value is 9 C. The value is 10 D. The value is 11

(9)Given the following code: public class Person{

static int arr[] = new int[10];

public static void main(String a[]) { System.out.println(arr[1];) } }

Which statement is correct? C

A. When compilation some error will occur.

B. It is correct when compilation but will cause error when running. C. The output is zero. D. The output is null.

(10)Given the following code: String s = \ String t = \

char c[] = {'h','e','l','l','o'} ; Which return true? AD

A. s.equals(t);

B. t.equals(c); C. s==t;

D. t.equals(new String(\ E. t==c. 1、C

2、A、B、E 3、C 4、A 5、A、B 6、D 7、A、D 8、C 9、C

10、A、D (二)、填空题(4′×5):

(1)、String str = new String (“Practical ”) ; str += “Java” ;

共产生几个对象:____5______。 (2)、递归函数sum(int a[],int n)的返回值是数组a[]的前n个元素之和 int sum(int a[],int n)

{ if (n>0) return __a[0]+sum(a+1,n-1)________; else __return 0; } (3)、short s1 = 1; s1 = s1 + 1和 short s1 = 1; s1 += 1; 那个可以编译通过,为什么

_____第二个 第一个 丢失精度_________________________________________________。 (4)、设int x=1,y=2,z=3,则表达式 y+=z--/++x的值是___3_________。 (5)、import java.util.*; class Int { private int i;

public Int(int ii) { i = ii; }

public void increment() { i++; } public String toString() { return Integer.toString(i); } }

public class test {

public static void main(String[] args) { ArrayList v = new ArrayList(); for(int i = 0; i < 10; i++ ) v.add(new Int(i));

System.out.println(\

ArrayList v2 = (ArrayList)v.clone(); for(Iterator e = v2.iterator(); e.hasNext(); )