1、JAVA双语教学考试试A卷及答案docx注意事项:请将各题答案按编号顺序填写到答题卷上,答在试卷上无效。-、单项选择题(120每小题1分,21*30每小题2分,共40分)Which statement of assigning a long type variable to a hexadecimal value is correct?A. 0|Pg 曲4.un I5.long number = 345L; B. long number = 0345;C. long number = 0345L; D. long number = 0x345L;Which layout manager is
2、used when the frame is resized the buttonss position in the Frame might be changed?A. BorderLayout B. FlowLayout C. CardLayout D. GridLayout Which are not Java primitive types?A. short B. Boolean C. byte D. floatGiven the following code:if (x0) System.out.println(firstn); else if (x-3) System.out.pr
3、intln(MsecondH); else System.out.println(MthirdH); Which range of x value would print the string usecond11?A. x 0 B. x -3 C. x = -3 D. x -37. Given the following code: public class Person int arr| | = new int| 10; public static void main(String a| ) System.out.println(arr| 11);Which statement is cor
4、rect?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. 14 B. 015 C. 0x14 D. 0129. A public member vairable called MAX_LENGTH wh
5、ich is int type, the value of thevariable 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 String
6、s?A. String a = f ; B. String a 5; C. String 5 a;D. String a = new String5; for (int i = 0; i 4)System.out.println(HTest An);else if(val 9)System.out.println(uTest Bn);else System.out.println(HTest CH);Which values of val will result in ”Test C” being printed:A. val 920. Which of the following are v
7、alid 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 voidmain( Graphics g );21. After the declaration:char c = new char100;what is the value of c50?A. 50 B. ” C. u0032 D.
8、 ,u0000,22. 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 (HelloJava);23.If arr contains only positive integer values, what does this function do?public int gu
9、essWhat(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 t
10、he array24. Which of the following are legal declarations of a two-dimensional array of integers?A. int55 a = new int; B. int a = new int5,5;C. int aJ = new int 55; D. inta = new 5int5;25.If val = 1 in the code below:switch (val)case 1: System.out.print(nPM);case 2:case 3: System.out.print (nQH);bre
11、ak;case 4: System.out.print(nRn);default: System.out.print (nSu);A. P B. PQ C. QS D. 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 argJ) 6.Test tl,t2;7.intj,k;&j=0; k=0;9.tl=new Test();10.t2=new Test(j,k);11
12、.12.Which line would cause one error during compilation?A. line 3 B. line 5 C. line 6 D. line 1027. For the code:m = 0;while( +m 2 )System.out.println(m);Which of the following are printed to standard output?A. 0 B. 1 C. 2 D. 328. Consider the following code: What will happen when you try to compile
13、 it?public class InnerClasspublic static void main(StringJargs)public class Mylnnerf 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. W
14、hat is the result of executing the following code:public class Testpublic static void main(String args) String word 二 MrestructureM;System.out.println(word.substring(2, 5);A. rest B. es C. str D. st30. What will be written to the standard output when the following program is run? public class Test p
15、ublic static void main(String argsfl) System.out.println(9 A 2);3L When call fact(3), What is the result?int fact(int n)if(n=l) return 1;elsereturn nfact(n-l);D. 0D. abedA. 2 B. 6 C. 332. What is the result of executing the following code: String s=new String(HabcdefgH);for(int i=0;is.length();i+=2)
16、System.out.print(s.char At(i);A. aceg B. bdf C. abcdefg33- What is the result of executing the following code: public class Test public static void changeStr(String str) str=nwelcomeH;public static void main(String args) String st” 12345”; changeStr(str);System.out.println(str);Please write the outp
17、ut result :A. welcome B. 12345 C. welcomel2345D. 12345welcome34. What is the result of executing the following code:1. public class Test 2. static boolean foo(char c) 3. System.out.print(c);4. return true;5. 6. public static void main( String argv ) 7. int i=0;& for ( foo(A); foo(B)&(i2); foo(C)9. i
18、+ ;10. foo(D);12. 13. 14. What is the result?A. ABDCBDCB B. ABCDABCDC. Compilation fails. D. An exception is thrown at runtime.35. What will happen when you attempt to compile and run the following code?public final class Test4class Innervoid test()if (Test4.this.flag);elsesample();private boolean f
19、lag=false;public void sample()System.out.println(HSampleH);public Test4()(new Inner().test();public static void main(String args) new Test4();What is the result:A. Print out SampleB Program produces no output but termiantes correctly.C. Program does not terminate.D. The program will not compile36. W
20、hat is the result of executing the following fragment of code: class Base Base()amethod();int i= 100;public void amethod()System.o u 匚 println(nBase.amethod()H);public class Derived extends Baseint i = -1;public static void main(String argv) Base b = new Derived();System.out.println(b.i); b.amethod(
21、);public void amethod()System.out.println(HDerived.amethod()n);A. Derived.amethod()Derived.amethod()C. 100Derived.amethod()B. Derived.amethod()100Derived.amethod() D. Compile time errorpublic class Test String sl=nmenun;public static void main(String args) int z=2;Test t=new Test();System.out.printl
22、n(t.sl+z);38. What is the result of executing the following code: public class Test implements A int x=5;public static void main(String args) Test cl = new Test();System.out.println(c l.x+A.k);interface A intk= 10;D. 105A. 5 B. 10 C. 1539- What is the result of executing the following code: import j
23、ava.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,Hzzzn); if(index=-l)System.out.println(HnoH);elseSystem.out.println(HyesH);A. no B. xxx C. 0 D. yesD. 35D. 16D. 3int b=2,3,4,5,6,7,8;int sum=O;for(int i=O;ivbength;i+) for(int j=O;jbiength;j+) sum+=biU;System.out.println(,sum=,4-sum);A. 9 B. 11 C. 1541. What is the result of executing t
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1