JAVA雙語(yǔ)教學(xué)考試試卷及答案A.docx_第1頁(yè)
JAVA雙語(yǔ)教學(xué)考試試卷及答案A.docx_第2頁(yè)
JAVA雙語(yǔ)教學(xué)考試試卷及答案A.docx_第3頁(yè)
JAVA雙語(yǔ)教學(xué)考試試卷及答案A.docx_第4頁(yè)
JAVA雙語(yǔ)教學(xué)考試試卷及答案A.docx_第5頁(yè)
已閱讀5頁(yè),還剩13頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

班 級(jí) 學(xué) 號(hào) 姓 名 密封裝訂線 密封裝訂線 密封裝訂線A卷注意事項(xiàng):請(qǐng)將各題答案按編號(hào)順序填寫到答題卷上,答在試卷上無效。一、單項(xiàng)選擇題(120每小題1分,2130每小題2分,共40分)1. Which are keywords in Java?A. NullB. TRUEC. sizeofD. implements2. Consider the following code:Integer s = new Integer(9);Integer t = new Integer(9);Long u = new Long(9);Which test would return true?A. (s.equals(new Integer(9)B. (s.equals(9)C. (s=u)D. (s=t)3. Which statement of assigning a long type variable to a hexadecimal value is correct? A. long number = 345L; B. long number = 0345;C. long number = 0345L; D. long number = 0x345L;4. Which layout manager is used when the frame is resized the buttonss position in the Frame might be changed? A. BorderLayout B. FlowLayoutC. CardLayoutD. GridLayout 5. Which are not Java primitive types? A. shortB. BooleanC. byteD. float 6. Given the following code:if (x0) System.out.println(first); else if (x-3) System.out.println(second); else System.out.println(third); Which range of x value would print the string second? A. x 0B. x -3C. x = -3D. x -3 7. Given the following code:public class Personint arr = new int10;public static void main(String a) System.out.println(arr1);Which statement is correct?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.8. Short answer:The decimal value of i is 13, the octal i value is: A. 14B. 015C. 0x14D. 0129. A public member vairable called MAX_LENGTH which is int type, the value of the variable remains constant value 100. Use a short statement to define the variable.A. public int MAX_LENGTH=100;B. final int MAX_LENGTH=100;C. final public int MAX_LENGTH=100;D. public final int MAX_LENGTH=100.10. Which correctly create an array of five empty Strings?A. String a = , , , , , ;B. String a 5;C. String 5 a; D. String a = new String5; for (int i = 0; i 4)System.out.println(Test A);else if(val 9)System.out.println(Test B);else System.out.println(Test C);Which values of val will result in Test C being printed:A. val 920. Which of the following are valid definitions of an applications main ( ) method?A. public static void main( );B. public static void main( String args );C. public static void main( String args );D. public static void main( Graphics g );21. After the declaration:char c = new char100;what is the value of c50?A. 50B. C. u0032D. u000022. Which of the following statements assigns Hello Java to the String variable s ?A. String s = Hello Java;B. String s = Hello Java;C. new String s = Hello Java;D. String s = new String (Hello Java);23. If arr contains only positive integer values, what does this function do?public int guessWhat(int arr)int x = 0;for(int i = 0; i arr.length; i+)x = x arri ? arri : x;return x;A. Returns the index of the highest element in the arrayB. Returns true/false if there are any elements that repeat in the arrayC. Returns how many even numbers are in the arrayD. Returns the highest element in the array24. Which of the following are legal declarations of a twodimensional array of integers?A. int55 a = new int;B. int a = new int5,5;C. int a = new int 55;D. inta = new 5int5;25. If val = 1 in the code below:switch (val)case 1: System.out.print(P);case 2:case 3: System.out.print (Q) ;break;case 4: System.out.print(R);default: System.out.print (S);A. PB. PQC. QSD. PQRS26. Given the following code:1. public class Test 2. int m, n;3. public Test() 4. public Test(int a) m=a; 5. public static void main(String arg) 6. Test t1,t2;7. int j,k;8. j=0; k=0;9. t1=new Test();10. t2=new Test(j,k);11. 12. Which line would cause one error during compilation?A. line 3B. line 5C. line 6D. line 1027. For the code:m = 0;while( +m 2 )System.out.println(m);Which of the following are printed to standard output?A. 0B. 1C. 2D. 328. Consider the following code: What will happen when you try to compile it?public class InnerClasspublic static void main(Stringargs)public class MyInner A. It will compile fine.B. It will not compile, because you cannot have a public inner class.C. It will compile fine, but you cannot add any methods, because then it will fail to compile.D. It will compile fail.29. What is the result of executing the following code:public class Test public static void main(String args) String word = restructure; System.out.println(word.substring(2, 5); A. restB. esC. strD. st30. What will be written to the standard output when the following program is run? public class Test public static void main(String args) System.out.println(9 2); A. 11B. 7C. 18D. 0 31. When call fact(3), What is the result?int fact(int n) if(n=1) return 1; else return n*fact(n-1); A. 2B. 6C. 3D. 0 32. What is the result of executing the following code:String s=new String(abcdefg);for(int i=0;is.length();i+=2) System.out.print(s.charAt(i); A. acegB. bdfC. abcdefgD. abcd33. What is the result of executing the following code:publicclassTestpublicstaticvoidchangeStr(Stringstr)str=welcome;publicstaticvoidmain(Stringargs)Stringstr=12345;changeStr(str);System.out.println(str);Pleasewritetheoutputresult:A. welcomeB. 12345C. welcome12345D. 12345welcome34. What is the result of executing the following code:1.publicclassTest2.staticbooleanfoo(charc)3.System.out.print(c);4.returntrue;5.6.publicstaticvoidmain(Stringargv)7. inti=0;8. for(foo(A);foo(B)&(i2);foo(C)9. i+;10. foo(D);12.13. 14.Whatistheresult?A.ABDCBDCBB.ABCDABCDC.Compilationfails.D.Anexceptionisthrownatruntime.35. What will happen when you attempt to compile and run the following code?public final class Test4 class Inner void test() if (Test4.this.flag); else sample(); private boolean flag=false; public void sample() System.out.println(Sample); public Test4() (new Inner().test(); public static void main(String args) new Test4(); What is the result: A. Print out “Sample” B. Program produces no output but termiantes correctly. C. Program does not terminate. D. The program will not compile 36. What is the result of executing the following fragment of code:class Base Base() amethod(); int i = 100; public void amethod() System.out.println(Base.amethod(); public class Derived extends Base int i = -1; public static void main(String argv) Base b = new Derived(); System.out.println(b.i); b.amethod(); public void amethod() System.out.println(Derived.amethod(); A. Derived.amethod()B. Derived.amethod() -1100 Derived.amethod()Derived.amethod()C. 100D. Compile time error Derived.amethod()37. What is the result of executing the following code:public class Test String s1=menu; public static void main(String args) int z=2; Test t=new Test(); System.out.println(t.s1+z); A. menu2B. 2C. 2menuD. menu38. What is the result of executing the following code:public class Test implements A int x=5; public static void main(String args) Test c1 = new Test(); System.out.println(c1.x+A.k); interface A int k= 10;A. 5B. 10C. 15D. 10539. What is the result of executing the following code:import java.util.Arrays;public class Test public static void main(String unused) String str = xxx, zzz,yyy,aaa; Arrays.sort(str); int index=Arrays.binarySearch(str,zzz); if(index=-1) System.out.println(no); else System.out.println(yes); A. noB. xxxC. 0D. yes40. What is the result of executing the following code:int b=2, 3, 4, 5, 6, 7, 8; int sum=0; for(int i=0;ib.length;i+) for(int j=0;jbi.length;j+) sum+=bij; System.out.println(sum=+sum);A. 9B. 11C. 15D. 35 41. What is the result of executing the following code:public class Test static void leftshift(int i, int j) i=j; public static void main(String args) int i=4, j=2; leftshift(i,j); System.out.println(i); A. 2B. 4C. 8D. 1642. What is the result of executing the following code:public class Test int x=2; int y; public static void main(String args) int z=3; Test t=new Test(); System.out.println(t.x+t.y+z); A. 5B. 23C. 2D. 3 43. What is the result of executing the following fragment of code: boolean flag = false;if (flag = true) System.out.println(true); else System.out.println(false);A. trueB. falseC. An exception is raisedD. Nothing happens44. In the following applet, how many buttons will be displayed? import java.applet.*; import java.awt.*; public class Q16 extends Applet Button okButton = new Button(Ok); public void init() add(okButton); add(okButton); add(okButton); add(new Button(Cancel); add(new Button(Cancel); add(new Button(Cancel); add(new Button(Cancel); setSize(300,300); A. 1 Button with label Ok and 1 Button with label Cancel.B. 1 Button with label Ok and 4 Buttons with label Cancel.C. 3 Buttons with label Ok and 1 Button with label Cancel.D. 4 Buttons with label Ok and 4 Buttons with label Cancel.45. What is the result of executing the following code:1. class StaticStuff 2. static int x = 10;3.static x += 5; 4. public static void main(String args)5. System.out.println(x = + x);6. 7. static x /= 5; 8. A. x = 10B. x = 15C. x = 3D. x=546. What will appear in the standard output when you run the Tester class? class Tester int var; Tester(double var) this.var = (int)var; Tester(int var) this(hello); Tester(String s) this(); System.out.println(s); Tester() System.out.println(good-bye); public static void main(String args) Tester t = new Tester(5); A. helloB. good-bye C. hello followed by good-byeD good-bye followed by hello47. What letters are written to the standard output with the following code? class Unchecked public static void main(String args) try method(); catch(Exception e) static void method() try wrench(); System.out.println(a); catch(ArithmeticException e) System.out.println(b); finally System.out.println(c); System.out.println(d); static void wrench() throw new NullPointerException(); Select all valid answers.A. aB. bC. cD. d48. Given this code snippet:try tryThis();return; catch(IOException x1) System.out.println(exception 1);return; catch(Exception x2) System.out.println(exception 2);return; finally System.out.println(finally);what will appear in the standard output if tryThis() throws a IOException?A. exception 1 followed by finallyB. exception 2 followed by finallyC. exception 1 D. exception 2二、填空題(每空1分,共10分) 1. JVM指的是Java【1】。2. Java中的字符變量在內(nèi)存中占【2】位(bit)。3. Java語(yǔ)言對(duì)簡(jiǎn)單數(shù)據(jù)類型進(jìn)行了類包裝,int對(duì)應(yīng)的包裝類是【3】。4. 繼承性是面向?qū)ο蠓椒ǖ囊粋€(gè)基本特征,它使代碼可【4】5. 抽象類中含有沒有實(shí)現(xiàn)的方法,該類不能【5】。6. 在Java的輸入輸出流中,數(shù)據(jù)從數(shù)據(jù)源流向數(shù)據(jù)目的地,流的傳送是【6】行的。7. 若類聲明時(shí)加上修飾符 final ,則表示該類不能有【7】。8. Java的類庫(kù)中提供Throwable類來描述異常,它有Error 和【8】?jī)蓚€(gè)直接子類。9. 類中的某些方法通過類名就可以直接被調(diào)用,例如JOptionPane.showMessage Dialog(null,”按確定鍵退出”)中的showMessageDialog 方法,這種方法稱為【9】。10. Java 的線程調(diào)度策略是一種基于優(yōu)先級(jí)的【10】式調(diào)度。三、寫出下面程序的功能或運(yùn)行結(jié)果(每小題4分,共20分)1. 下面程序的功能是什么?public class Exam1 public static void main(String args) for(int i=1; i10; i+) for(int j=1; j=i; j+) System.out.print(j + * + i + = + j*i + ); if(j*i10)System.out.print( ); System.out.println(); 2. 下面程序的功能是什么?public class Exam2 public static void main(String args) int x = 2, y = 1, t; double sum = 0; for(int i=1; i=15; i+) sum = sum + (double)x/y; t = y; y = x; x = y + t; System.out.println(Sum= + sum);3. 下面程序的功能是什么?import java.util.*;public class lianxi29 public static void main(String args) Scanner s = new Scanner(System.in); int a = new int33;System.out.println(請(qǐng)輸入9個(gè)整數(shù):); for(int i=0; i3; i+) for(int j=0; j3; j+) aij = s.nextInt(); System.out.println(

溫馨提示

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

最新文檔

評(píng)論

0/150

提交評(píng)論