中兴面试测试题

面试测试题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 (" The value of j is " + j );

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("condition 1");

} catch (ArrayIndexOutOfBoundsException e) {

System.out.println("condition 2");

} catch(Exception e) {

System.out.println("condition 3");

} finally {

System.out.println("finally");

}

}

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("The value is"+m);

}

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 = "hello";

String t = "hello";

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("hello"));

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

v.add(new Int(i));

System.out.println("v: " + v);

ArrayList v2 = (ArrayList)v.clone();

for(Iterator e = v2.iterator();

e.hasNext(); )

((Int)e.next()).increment();

System.out.println("v: " + v);

}

}

上面这段代码输出什么 v: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

___v: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]______________________________________。

1、5个

2、a[n-1]+sum(a,n-1) 或 a[0]+sum(a+1,n-1)

return 0

3、第二个(第一个丢失精度)

4、3

5、v: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

v: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

(1)、(15′) 请编写程序打印下列图案:

*********

*******

*****

***

(2)、(25′)Java 异常处理机制测试

继承Exception 类编写一个自定义异常类MyException, 在自定义异常类中加入一个方法getMyMessage(),此方法无参数, 返回值为一个字符串, 字符串内容为你的自定义异常信息:"你的姓名:" + Exception的getMessage()方法的返回值. 格式如:

(姓名:***Exception***)。

编写一个类ExceptionMaker, 在里面定义一个方法throwException(),在这个方法中制造一种异常情况, 抛出一个JDK 自带的异常, 捕捉这个异常, 并在catch 处理语句中抛出你的自定义异常MyException, 抛出的自定义异常要求保留原异常的信息(getMessage()的返回值);

再编写一个类MyExceptionTestCase, 测试你编写的前面两个类, 调用第二个类中的抛出你自定义异常的方法throwException(),捕捉你的自定义异常, 并输出你自定义的异常信息. 答案

(三)编程题

1、

public class Test01 {

public static void main(String[] args) {

int i, j, t, c;

j = 1;

t = 9;

c = 5;

while(c > 0){

for(i = 0; i

System.out.print(" ");

}

j++;

for(i = 0; i

System.out.print("*");

}

t -= 2;

System.out.println();

c--;

}

}

}

2、/**

* 自定义的异常类

*/

class MyException extends Exception {

private String str;

/**

* 抛出异常

*@return 抛出异常串

*/

public String getMyMessage() {

return str;

}

/**

* 构造自定义异常

*@param 发生的异常

*/

public MyException(Exception e) {

Exception excep = new Exception(e);

str = "zhanggenbo" + excep.getMessage();

}

}

/**

* 自定义的异常类

*/

class ExceptionMaker {

/**

* 扑获异常

*/

public void throwException() throws ArithmeticException, MyException { try {

int i = 3 / 0;

} catch (ArithmeticException e) {

System.out.println(e.getMessage());

throw new MyException(e);

}

}

}

/**

* 测试异常类文件

*@author 张根波

*/

public class MyExceptionTestCase {

/**

* 测试异常

*@param arg 入口参数

*/

public static void main(String arg[]) {

ExceptionMaker em = new ExceptionMaker(); try {

em.throwException();

} catch (MyException e) {

System.out.println(e.getMyMessage()); }

}

}

面试测试题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 (" The value of j is " + j );

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("condition 1");

} catch (ArrayIndexOutOfBoundsException e) {

System.out.println("condition 2");

} catch(Exception e) {

System.out.println("condition 3");

} finally {

System.out.println("finally");

}

}

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("The value is"+m);

}

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 = "hello";

String t = "hello";

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("hello"));

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

v.add(new Int(i));

System.out.println("v: " + v);

ArrayList v2 = (ArrayList)v.clone();

for(Iterator e = v2.iterator();

e.hasNext(); )

((Int)e.next()).increment();

System.out.println("v: " + v);

}

}

上面这段代码输出什么 v: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

___v: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]______________________________________。

1、5个

2、a[n-1]+sum(a,n-1) 或 a[0]+sum(a+1,n-1)

return 0

3、第二个(第一个丢失精度)

4、3

5、v: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

v: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

(1)、(15′) 请编写程序打印下列图案:

*********

*******

*****

***

(2)、(25′)Java 异常处理机制测试

继承Exception 类编写一个自定义异常类MyException, 在自定义异常类中加入一个方法getMyMessage(),此方法无参数, 返回值为一个字符串, 字符串内容为你的自定义异常信息:"你的姓名:" + Exception的getMessage()方法的返回值. 格式如:

(姓名:***Exception***)。

编写一个类ExceptionMaker, 在里面定义一个方法throwException(),在这个方法中制造一种异常情况, 抛出一个JDK 自带的异常, 捕捉这个异常, 并在catch 处理语句中抛出你的自定义异常MyException, 抛出的自定义异常要求保留原异常的信息(getMessage()的返回值);

再编写一个类MyExceptionTestCase, 测试你编写的前面两个类, 调用第二个类中的抛出你自定义异常的方法throwException(),捕捉你的自定义异常, 并输出你自定义的异常信息. 答案

(三)编程题

1、

public class Test01 {

public static void main(String[] args) {

int i, j, t, c;

j = 1;

t = 9;

c = 5;

while(c > 0){

for(i = 0; i

System.out.print(" ");

}

j++;

for(i = 0; i

System.out.print("*");

}

t -= 2;

System.out.println();

c--;

}

}

}

2、/**

* 自定义的异常类

*/

class MyException extends Exception {

private String str;

/**

* 抛出异常

*@return 抛出异常串

*/

public String getMyMessage() {

return str;

}

/**

* 构造自定义异常

*@param 发生的异常

*/

public MyException(Exception e) {

Exception excep = new Exception(e);

str = "zhanggenbo" + excep.getMessage();

}

}

/**

* 自定义的异常类

*/

class ExceptionMaker {

/**

* 扑获异常

*/

public void throwException() throws ArithmeticException, MyException { try {

int i = 3 / 0;

} catch (ArithmeticException e) {

System.out.println(e.getMessage());

throw new MyException(e);

}

}

}

/**

* 测试异常类文件

*@author 张根波

*/

public class MyExceptionTestCase {

/**

* 测试异常

*@param arg 入口参数

*/

public static void main(String arg[]) {

ExceptionMaker em = new ExceptionMaker(); try {

em.throwException();

} catch (MyException e) {

System.out.println(e.getMyMessage()); }

}

}


相关文章

  • 中兴笔试面试题
  • 中兴2009 1>某人在某个市场某个商家买了某台电脑,请用你熟悉的计算机语言表达出里面的关系. 其中有商家类,买家类,商品类.还要有买方法,卖方法. 2>一个完整的单例模式 3>曹操南下攻打刘备,刘备派关羽守锦州,关羽派张 ...查看


  • 中兴专业面试试题 (1)
  • 本试卷分三部分,公共部分.C++部分和JA V A 部分,其中公共部分为必考部分,C++与JA V 部分,两者选一完成.试卷满分100分. 公共部分(50分) 1:分时操作系统通常采用___ B ____策略为用户服务.(4分) A. 可靠 ...查看


  • 中兴笔试和面试全过程
  • 签约中兴全过程 好久没有动手自己写东西了,一是太忙碌,二是没有特别值得写的东西,如今找工作终于尘埃落定,突然一下闲下来,反而觉得有点茫然.于是聊以自娱,把找工作过程记录下,一方面纪念自己找工作的过程,另一方面总结自己,练练文字. 九月七号下 ...查看


  • 2013年各大小IT公司待遇,来自西电(转)
  • 2012-11-10 18:29:13|  分类: 求职 |字号 订阅 本人西电硕士,根据今年找工作的情况以及身边同学的汇总,总结各大公司的待遇如下,吐血奉献给各位学弟学妹,公司比较全,你想去的公司不在这里面,基本上是无名小公司了:无名小公 ...查看


  • 中兴校园面试经验
  • 中兴面试经验 导语:商立方高端商务平台根据自己用户真实体验,整理出用户的面试经验,与大家分享,共同进步. 大概在笔试三天之后收到了一面通知,由于这次中兴招聘以研究生为主所以本科生面试时间比较晚. 一面是专业面试.去之前一直在准备硬件的知识, ...查看


  • IT行业工资表(最新-已修改)
  • 09届IT行业晒工资(版本1) 最近终于把自己给卖了,这几个月来自己陆陆续续的面试的有30多家公司,主要是IT公司,准备把今年我所知道的IT公司的待遇薪水总结一下,这里面包括我自己找工作所知道的,我们系的其他同学已经拿到的offer,基本上 ...查看


  • 中兴实习生管理办法
  • ZD/ZX 中兴通讯股份有限公司企业制度 (人事管理制度系统) ZD/ZX 04.035 3-2002 实习生管理办法 2002-09-11 发布 2002-09-11 实施 起草部门:人事中心 HR 部 主要起草人:杨蜀武 企业制度 ZD ...查看


  • 中国移动面试题
  • 中国移动面试题总结 中国移动笔试题面试题 1.TCP/IP有几层,都是什么? 4层, 2.3G都有哪几种标准? 3.对移动通信的各个部分有多少的了解? 4.你对运行商怎么选择3G的看法? 5.介绍一下自己的家庭.教育背景.研究经验等等 6. ...查看


  • 总结心得篇
  • --总结心得篇 从暑假找实习开始,自己就给自己做了一个承诺,不论今年找工结果如何,都要把这段时间的经历总结一下,作为纪念也好,分享感悟也好,希望能够带给大家一些帮助,也让自己有所沉淀.此贴只是单纯想对所有关心和帮助过我的朋友们表示感谢,也同 ...查看


热门内容