中興面試測試題_第1頁
中興面試測試題_第2頁
中興面試測試題_第3頁
中興面試測試題_第4頁
中興面試測試題_第5頁
免費(fèi)預(yù)覽已結(jié)束,剩余1頁可下載查看

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、面試測試題2(一)、選擇題(4' X 10):( 1 ) Which of the following range of short is correct? CA. -27 27-1 B. 0 216-1C. -215 215-1 D. -231 231-1( 2) Which declarations of identifiers are legal? ABEA. $persons B. TwoUsers C. *point D. this E. _endline( 3) Given the following code: C1: public void modify() 2:int

2、 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? CA. 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 o

3、ctal number? AA. 010 B. 0x10 C. 08 D. 0x8( 5) Which are not Java keywords?ABA. 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 pri

4、ntValue() /. 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? DA. on line 2 B. on line 3 C. on line 6 D. on line 7( 7) Given the following code:public void test() try oneMeth

5、od();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? ADA. c

6、ondition 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? CA. The

7、 value is 8B. The value is 9C. The value is 10D. The value is 11( 9) Given the following code:public class Personstatic int arr = new int10;public static void main(String a) System.out.println(arr1;)Which statement is correct? CA. When compilation some error will occur.B. It is correct when compilat

8、ion 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? ADA. s.equals(t);B. t.equals(c);C. s=t;D.

9、 t.equals(new String("hello");E. t=c.1、 C2、 A、 B、 E3、 C4、 A5、 A、 B6、 D7、 A、 D8、 C9、 C10、 A、 D(二)、填空題(4' X 5):(1) 、 String str = new String ( “ Practical ” ) ;str +=“ Java ” ;共產(chǎn)生幾個對象:5。(2)、遞歸函數(shù)sum(int a,int n)的返回值是數(shù)組a口的前n個元素之和int sum(int a,int n) if (n>0) return _a0+sum(a+1,n-1);else

10、 _return 0;( 3) 、 short s1 = 1; s1 = s1 + 1 和 short s1 = 1; s1 += 1; 那個可以編譯通過,為什么第二個第一個 丟失精度( 4) 、設(shè) int x=1,y=2,z=3, 則表達(dá)式y(tǒng)+=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

11、 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("v: " + v);ArrayList v2 = (ArrayList)v.clone();for(Iterator e = v2.iterator();e.hasNext(); )(Int)e.next().increment();System.out.println("v:

12、 " + 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、 an-1+sum(a,n-1) 或 a0+sum(a+1,n-1) return 03、第二個(第一個丟失精度)4、 35、 v: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9v: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10(1)、(15')請編寫程序打印下列圖案:(2)、(25' Java異常處理機(jī)制測試?yán)^承 Exception 類編寫一個自定義異常類MyE

13、xception, 在自定義異常類中加入一個方法getMyMessage(), 此方法無參數(shù),返回值為一個字符串,字符串內(nèi)容為你的自定義異常信息:"你的姓名:"+ Exception的getMessage()方法的返回值.格式如:(姓名 :*Exception* ) 。編寫一個類ExceptionMaker, 在里面定義一個方法throwException(), 在這個方法中制造一種異常情況 拋出一個JDK自帶的異常,捕捉這個異常,并在catch處理語句中拋出你的自定義異常MyException,拋出的自定義異常要求保留原異常的信息(getMessage()的返回值);再編

14、寫一個類MyExceptionTestCase, 測試你編寫的前面兩個類,調(diào)用第二個類中的拋出你自定義異常的方法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 <= j; i+)System.out.print(" ");j+;for(i = 0; i < t; i+)Syst

15、em.out.print("*");t -= 2;System.out.println();c-;2、/* 自定義的異常類*/class MyException extends Exception private String str;/*拋出異常return 拋出異常串*/public String getMyMessage() return str;/*構(gòu)造自定義異常param 發(fā)生的異常*/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 MyExce

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論