311020040面向对象程序设计导论_双语_B闭_
合集下载
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
311020040 面向对象程序设计导论(双语) (B 闭)
2012-2013-1
a. ASCII b. bytecode c. Unicode d. EBCDIC 10. Objects maintain their own state via a. Their superclass parts b. Their static variables c. Their instance variables d. Their local variables 11. A collection typically models a _____ relationship. a. zero-to-one b. one-to-many c. many-to-many d. one-to-one 12. A relationship that exists between two specific instances of an object is known as ano a. association b. aggregation c. specialization d. link 13. Which of the following statements about constructors in Java is true? a. A class must define at least one constructor. b. A class can define more than one constructor. c. A constructor must be defined as public. d. A constructor must be defined as static. 14. What is used to indicate that a method does not return a value? a. the keyword void b. the name of the class to which it belongs c. the omission of the return type d. the keyword static 15. When a subclass defines an instance method with the same return type and signature as a method in its parent, the parent's method is said to be a. hidden b. overridden c. private d. overloaded 16. Which is a Java access modifier used to designate that a particular data field will not be inherited by a subclass? a. final b. default c. protected d. private 17. If the method int sum(int a, int b) is defined in a Java class C, which of the following methods cannot coexist as a different method in class C? a. int sum(float a, int b) b. int sum(int x, float y) c. int sum(int x, int y) d. float sum(int x, float y) 18. How many lines of output will be produced by the following code fragment? for (int i = 0; i < 4; ++i) { for (int j = 1; j < 3 ; ++j) { stdOut.println(i + j); a. 6 b. 8 c. 10 d. 12 19. Which of the following is a Java event that is generated when the close button on a JFrame component is pressed? a. ExitEvent b. WindowEvent c. CloseEvent d. DisposeEvent 20. Consider the following Java class definitions public class Object1 { protected String d(){ return "Hi"; } } public class Object2 extends Object1 { protected String d(){ return super.d(); }
311020040 面向对象程序设计导论(双语) (B 闭)
一、单项选择题(本大题共 40 小题,每小题 1 分,共 40 分)
2012-2013-1
提示:在每小题列出的四个备选项中只有一个是符合题目要求的,请将其代码填写在下表中。错选、多选或 未选均无分。
1.What is the right way to handle abnormalities in input on Java? a. By writing while loops to guard against bad input b. By always specifying the throws clause in every method header where file I/O is performed c. By using the class FileFilter which gracefully filters out bad input data d. By handling these problems by providing exception handlers 2. What will be output caused by the execution of the following Java program segment? String name = "Elvis"; System.out.print(name + "was here"); a. name was here b. Elvis was here c. Elviswas here d. name + was here 3. The name of a Java source file a. has no restrictions b. must be the same as the class it defines, respecting case c. must use the extension .class d. must be the same as the class it defines, ignoring case 4. Classes from which of the following packages are implicitly imported into every Java program? a. ng b. java.util c. java.io d. java.awt 5. Which of the following is true regarding Java applications? a.They are run using a Java interpreter. b.They are compiled into machine code. c. They are interpreted by a Web browser. d. They are platform-dependent. 6. What is the name of the JDK program that processes Javadoc comments? a. javadoc b. java c. javacom d. javac 7. Which of the following statements is true of the conventions outlined by Sun Microsystems in the document entitled Code Conventions for the Java Programming Language? 1. They define a standard interface definition language that must be used for all Java classes. 2. They provide recommendations intended to make source code easier to read and understand. 3. They describe one mechanism for network communication between Java and C++ programs. a. I, II, and III b. I and III only c. II only d. III only 8. What is the correct ordering for the import, class and package declarations when found in a single file? a. package, import, class b. package, class, import c. class, import, package d. import, package, class 9. The coding system used to represent characters in Java is
311020040 面向对象程序设计导论(双语) (B 闭)2012-2013-1
} Which of the following statements is (are) true regarding the definitions? I .Class Object2 inherits from class Object1. II Class Object2 overrides method d. III Method d returns equivalent results when executed from either class a. I and II only b. I, II, and III c. III only d. I and III only 21. Given the following code, what value will be output by the last statement? StringTokenizer st = new StringTokenizer("this is,a,test of tokens", ","); String s; int count = 0; while (st.hasMoreTokens()) { s = st.nextToken(); ++count; } stdOut.println(count); a. 3 b. 6 c. 4 d. 1 22. In programming, a loop is generally used to achieve a. branching b. succession c. selection d. repetition 23. Consider the following Java program segment. int x = 5; int y = 2; System.out.println(x + "1" + y); Which of the following statements is true about the program segment? a. The output caused by the code will be 8. b. The code will cause a compilation error. c. The output caused by the code will be 5 1 2. d. The output caused by the code will be 512. 24. Given the function below, what is the value of f( 8, 9 )? private int f( int x, int y ) { if( x == 0 ) { return y; } else { return f( x - 1, y + 1 ); } } (a) 0 (b) 17 (c) This recursion is incorrect in some way. (d) 72 25. Which of the following statements is (are) true about inheritance in Java? I. A class can extend more than one abstract class. II. A class can implement more than one interface. a. II only b. I and II c. None d. I only 26. Which of the following statements is (are) true about interfaces in Java? I. Interfaces can extend other interfaces. II. Interfaces can contain data fields. a. II only b. None c. I only d. I and II 27. A design pattern is typically used to a. describe a practical solution to a common design problem