分享
结业考试20060601.doc
下载文档

ID:3433393

大小:90KB

页数:15页

格式:DOC

时间:2024-04-30

收藏 分享赚钱
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,汇文网负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。
网站客服:3074922707
结业 考试 20060601
Java结业测试题 考试时间:180分钟 姓名:________________ 选择题: (每题1 分, 共50分) 1. Given the following code: class Test{ private int m; public static void fun() { // some code... } } How can the member variable m be accessible directly in the method fun()? A. change private int m to protected int m B. change private int m to public int m C. change private int m to static int m D. change private int m to int m 2. Which methods are correct overloading methods of the following method: public void example(){...} A. public void example( int m){...} B. public int example(){...} C. public void example2(){...} D. public int example ( int m, float f){...} 3. Given the following fragment of code: public class Base{ int w, x, y ,z; public Base(int a,int b){ x=a; y=b; } public Base(int a, int b, int c, int d){ // assignment x=a, y=b w=d; z=c; } } Which expressions can be used at the point of // assignment x=a, y=b? A. Base(a,b); B. x=a, y=b; C. x=a; y=b; D. this(a,b); 4. Given the following definition: String s = "story"; Which of the following expressions are legal? A. s += "books"; B. char c = s[1]; C. int len = s.length; D. String t = s.toLowerCase(); 5. What is the return value of the main() method in Java? A. String B. int C. char D. void 6. Which are the valid identifiers in Java? A. fieldname B. super C. 3number D. #number E. $number 7. Which are valid Java keywords? A. const B. NULL C. false D. this E. native 8. Which are valid integral expressions in Java? A. 22 B. 0x22 C. 022 D. 22H 9. Given the following fragment of code, what are results of i and j after execution? int i = 1; int j; j = i++; A. 1, 1 B. 1, 2 C. 2, 1 D. 2, 2 10. Which of the following statements are true? A. >> is the arithmetic right shift operator. B. >> is the logical right shift operator. C. >>> is the arithmetic right shift operator. D. >>> is the logical right shift operator. 11. Which of the following assignments are legal? A. float a = 2.0 B. double b = 2.0 C. int c = 2 D. long d = 2 12. Which one of the following arguments is the correct argument of the main() method? A. char args[] B. char args[][] C. String arg[] D. String args 13. Which one of the following is correct to create an array? A. float f[][] = new float[6][6]; B. float []f[] = new float[6][6]; C. float f[][] = new float[][6]; D. float [][]f = new float[6][6]; E. float [][]f = new float[6][]; 14. Given the following expression: int m[] = {0, 1, 2, 3, 4, 5, 6 }; Which result of the following expressions equals to the number of the array elements? A. m.length() B. m.length C. m.length()+1 D. m.length+1 15. Given the following command to run a correct class: java MyTest a b c Which statements are true? A. args[0] = "MyTest a b c" B. args[0] = "MyTest" C. args[0] = "a" D. args[1]= 'b' 16. Given the following code: public class Test{ static long a[] = new long[10]; public static void main ( String arg[] ) { System.out.println ( a[6] ); } } Which statement is true? A. Output is null. B. Output is 0. C. When compile, some error will occur. D. When running, some error will occur. 17. Given the following fragment of code: boolean m = true; if ( m = false ) System.out.println("False"); else System.out.println("True"); What is the result of the execution? A. False B. True C. None D. An error will occur when running. 18. Given the following code: public class Test{ public static void main(String arg[]){ int i = 5; do { System.out.println(i); } while (--i>5); System.out.println(“Finished”); } } What will be output after execution? A. 5 B. 4 C. 6 D. Finished E. None 19. What will be output after execution of the following code: outer: for(int i=0;i<3; i++) inner: for(int j=0;j<2;j++) { if(j==1) continue outer; System.out.println(j++ + “and” + ++i); } A. 0 and 0 B. 0 and 1 C. 0 and 2 D. 1 and 0 E. 1 and 1 F. 1 and 2 G. 2 and 0 H. 2 and 1 I. 2 and 2 20. Given the following code: switch (m) { case 0: System.out.println("Condition 0"); case 1: System.out.println("Condition 1"); case 2: System.out.println("Condition 2"); case 3: System.out.println("Condition 3");break; default: System.out.println("Other Condition"); } Which values of m will cause "Condition 2" is output? A. 0 B. 1 C. 2 D. 3 E. 4 F. None 21. Which modifiers are legal in Java? A. private B. public C. protected D. protect E. friend 22. If a member variable of a class can be accessible only by the same package, which modifier should be used? A. private B. public C. protected D. no modifier E. final 23. Which modifier should be used to define a constant member variable? A. static B. final C. abstract D. No modifier can be used 24. Given the following definition of a class: public class Test { private float f = 1.0f; int m = 12; static int n=1; public static void main(String arg[]) { Test t = new Test(); // some code... } } Which of the following usage are legal? A. t.f B. this.n C. Test.m D. Test.n 25. Given the following code: 1) class Example{ 2) String str; 3) public Example(){ 4) str= "example"; 5) } 6) public Example(String s){ 7) str=s; 8) } 9) } 10) class Demo extends Example{ 11) } 12) public class Test{ 13) public void f () { 14) Example ex = new Example("Good"); 15) Demo d = new Demo("Good"); 16) } Which line will cause an error? A. line 3 B. line 6 C. line 10 D. line 14 E. line 15 26. Given the following class definition in one source file: class Base { public Base (){ //... } public Base ( int m ){ //... } protected void fun( int n ){ //... } } public class Child extends Base{ // member methods } Which methods can be added into the Child class correctly? A. private void fun( int n ){ //...} B. void fun ( int n ){ //... } C. protected void fun ( int n ) { //... } D. public void fun ( int n ) { //... } E. public m(){ //... } 27. Which statements are correct? A. In Java single inheritance is allowed, which makes code more reliable. B. A subclass inherits all methods ( including the constructor ) from the superclass. C. A class can implement as many interfaces as needed. D. When a class implements an interface, it can define as many methods of the interface as needed. 28. In the Test.java source file, which are correct class definitions? A. public class test { public int x = 0; public test(int x) { this.x = x; } } B. public class Test{ public int x=0; public Test(int x) { this.x = x; } } C. public class Test extends T1, T2 { public int x = 0; public Test (int x) { this.x = x; } } D. public class Test extends T1{ public int x=0; public Test(int x){ this.x = x; } } E. protected class Test extends T2{ public int x=0; public Test(int x){ this.x=x; } } 29. The Person, Student and Teacher are class names. These classes have the following inheritance relation as shown below: Person | --------------- | | Student Teacher There is the following expression in a Java source file: Person p = new Student(); Which one of the following statements are true? A. The expression is legal. B. The expression is illegal. C. Some errors will occur when compile. D. Compile is correct but it will be wrong when running. 30. The Person, Student and Teacher are class names. These classes have the following inheritance relation as shown below: Person | --------------- | | Student Teacher In Java source file a specific method has an argument. In order to handle all these classes in this method which type of argument of this method should be used? A. Person B. Student C. Teacher D. Object E. None of them can be used. 31. .The Person, Student and Teacher are class names. These classes have the following inheritance relation as shown below: Person | --------------- | | Student Teacher There is the following expression in a Java source file: Person p = new Teacher(); Which of the following expressions return true? A. p instanceof Teacher B. p instanceof Student C. p instanceof Person D. None of them returns true 32. Given the following code: public class Test{ public static void main(String args[]) { String str=new String("World"); char ch[]={'H','e','l','l','o'}; change(str,ch); System.out.println(str + "and" + ch); } public static void change(String str, char ch[]) { str="Changed"; ch[0]='C'; } } What is the result after execution? A. World and Hello B. World and Cello C. Changed and Hello D. Changed and Cello E. none of above 33. Given the following fragment of code: Double d1 = new Double(1.0); Double d2 = new Double(1.0); Float f = new Float(1.0F); Which results of the following expressions are true? A. d1 == d2 B. d1.equals(d2) C. d1 = f D. f.equals(d1) 34. Given the following code: public void fun () { int i; try { i=System.in.read (); System.out.println("Location 1"); } catch (IOException e) { System.out.println("Location 2"); } finally { System.out.println("Location 3"); } System.out.println("Location 4"); } If an IOException occurs, what will be printed? A. Location 1 B. Location 2 C. Location 3 D. Location 4 35. If the method func() is allowed to throw out the IOException, which declaration of this method can used? A. public int func(int i) B. public int func(int i) throw IOException C. public int func(int i) throw Exception D. public int func(int i) throws IOException E. public int func(int i) throws Exception 36. Consider the following class: 1. class Test { 2. void test(int i) { 3. System.out.println("I am an int."); 4. } 5. void test(String s) { 6. System.out.println("I am a string."); 7. } 8. 9. public static void main(String args[]) { 10. Test t=new Test(); 11. char ch=’y’; 12. t.test(ch); 13. } 14. } Which of the statements below is true?(Choose one.) A. Line 5 will not compile, because void methods cannot be overridden. B. Line 12 will not compile, because there is no version of test() that rakes a char argument. C. The code will compile but will throw an exception at line 12. D. The code will compile and produce the following output: I am an int. E. The code will compile and produce the following output: I am a String. 37. Which of the following fragments might cause errors? A. String s = "Gone with the wind"; String t = " good "; String k = s + t; B. String s = "Gone with the wind"; String t; t = s[3] + "one"; C. String s = "Gone with the wind"; String standard = s.toUpperCase(); D. String s = "home directory"; String t = s - "directory". 38. Which of the following answer is correct to express the value 8 in octal number? A. 010 B. 0x10 C. 08 D. 0x8 39. Which of the following assignment is not correct? A. float f = 11.1; B. double d = 5.3E12; C. double d = 3.14159; D. double d = 3.14D. 40. Which of the following statements about variables and their scopes are true? A. Instance variables are member variables of a class. B. Instance variables are declared with the static keyword. C. Local variables defined inside a method are created when the method is executed. D. Local variables must be initialized before they are used. 41. Which of the following statements about declaration are true? A. Declaration of primitive types such as boolean, byte and so on does not allocate memory space for the variable. B. Declaration of primitive types such as boolean, byte and so on allocates memory space for the variable. C. Declaration of nonprimitive types such as String, Vector and so on does not allocate memory space for the object. D. Declaration of nonprimitive types such as String, Vector ans so on allocates memory space for the object. 42. Which fragments are correct in Java source file? A. package testpackage; public class Test{//do something...} B. import java.io.*; package testpackage; public class Test{// do something...} C. import java.io.*; class Person{// do something...} public class Test{// do something...} D. import java.io.*; import java.awt.*; public class Test{// do something...} 43. class Parent { String one, two; public Parent(String a, String b){ one = a; two = b; } public void print(){ System.out.println(one); } } public class Child extends Parent { public Child(String a, String b){ super(a,b); } public void print(){ System.out.println(one + " to " + two); } public static void main(String arg[]){ Parent p = new Parent("south", "north"); Parent t = new Child("east", "west"); p.print(); t.print(); } } Which of the following is correct? A. Cause error during compilation. B. south east C. south to north east to west D. south to north east E. south east to west 44. Given the uncompleted method: 1) 2) { success = connect(); 3) if (success==-1) { 4) throw new TimedOutException(); 5) } 6)} TimedOutException is not a RuntimeException. Which can complete the method of declaration when added at line 1? A. public void method() B. public void method() throws Exception C. public void method() throws TimedOutExceptio

此文档下载收益归作者所有

下载文档
你可能关注的文档
收起
展开