




已阅读5页,还剩8页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
单项选择115题1. Which is the Java keyword used to denote a class method? (a) class (b) static (c) private (d) final 2. The term class variable is a synonym for (a) a read-only variable (b) a private data field (c) a static data field (d) an instance variable 3. Which of the following statements about class variables in Java is not true? (a) Non-static methods in a class can access the class variable defined in the same class. (b) All objects have their own copy of the class variable defined in the instantiated class. (c) Class variables require the modifier static in the declarations. (d) Class variables do not need the reference to the object of the instantiated class to access them. 4. Consider the following UML class diagram. The diagram describes a (a) one-to-one relationship (b) relationship between a subclass and a superclass (c) self-containing class (d) class without methods 5. When using noun-phrase analysis to model a software system, which of the following should typically be eliminated from the list of potential classes? I .References to the software system itself II .Nouns that imply roles between objects III .Synonyms to other nouns in the list (a) I and III only (b) I, II, and III (c) III only (d) II and III only 6. 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 static. (d) A constructor must be defined as public. 7. If a(n) _ exception can occur in a method that does not have a catch block to handle that exception, then a throws clause that lists this exception must be part of the method _. (a) unchecked, body (b) checked, body (c) checked, header (d) unchecked, header 8. If a class contains a constructor, that constructor will be invoked (a) once at the beginning of any program that uses that class (b) each time an object of that class is instantiated (c) once the first time an object of that class is instantiated (d) each time an object of that class goes out of scope 9. Consider the following Java program segment.import java.io.*;public class Test public Test( ) System.out.println(default); public Test( int i ) System.out.println(non-default); public static void main(String args) Test t = new Test(2); Which of the following will be output during execution of the program segment? (a) The line of text default (b) The line of text default followed by the line of text non-default (c) The line of text non-default followed by the line of text default (d) The line of text non-default 10. From within a child class, its parent class is referred to via the keyword (a) super (b) this (c) parent (d) base 11. Which of the following statements imports the entire package java.util into a Java program? (a) import util; (b) import util.*; (c) import java.util.*; (d) import java.util; 12. 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(); 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, II, and III (b) I and II only (c) I and III only (d) III only 13. After a breakpoint is hit, a debugger is typically used for which of the following tasks? I. Stepping through method calls, line by line II. Examining a stack trace III. Examining values of variables in the current method (a) I and III only (b) I and II only (c) II only (d) I, II, and III 14. Which is a Java access modifier used to designate that a particular data field will not be inherited by a subclass? (a) private (b) final (c) protected (d) default 15. 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(int x, float y) (b) int sum(float a, int b) (c) float sum(int x, float y) (d) int sum(int x, int y) 16. The name of a Java source file (a) must use the extension .class (b) must be the same as the class it defines, respecting case (c) has no restrictions (d) must be the same as the class it defines, ignoring case 17. Which package does not need to be explicitly imported into a Java program? (a) java.io (b) java.lang (c) java.applet (d) java.awt 18. Given the following code, how many tokens will be output? StringTokenizer st = new StringTokenizer(this is a test);while (st.hasMoreTokens() stdOut.println(st.nextToken() ); (a) 1 (b) 0 (c) 4 (d) 3 19. Consider an object stdIn instantiated by the Java statement below. private static java.io.BufferedReader stdIn = new java.io.BufferedReader( new java.io.InputStreamReader(System.in);Which of the following lines of code can be used to read an integer value from stdIn? (a) int value = stdIn.readInteger(); (b) int value = Integer.parseInt(stdIn.readLine(); (c) int value = stdIn.readLine(); (d) int value = Integer.parseInt(stdIn); 20. What will be output when the following Java program segment is executed? int x = 5; int y = 2; System.out.println(x + y); (a) 7 (b) 52 (c) 5 2 (d) 5+2 21. A difference between the methods print and println of the class java.io.PrintWriter is that (a) print inserts a new line at the beginning of its output, but println does not (b) println inserts a new line at the beginning of its output, but print does not (c) print appends a new line to the end of its output, but println does not (d) println appends a new line to the end of its output, but print does not 22. In Java, exceptions that are not handled are passed up the (a) block hierarchy (b) call stack (c) exception ladder (d) catch blocks 23. All Java exception classes are derived from the class (a) java.lang.Error (b) java.lang.Throwable (c) java.io.IOException (d) java.lang.RuntimeException 24. Which of the following is true regarding Java applications? (a) They are platform-dependent. (b) They are compiled into machine code. (c) They are interpreted by a Web browser. (d) They are run using a Java interpreter. 25. Which method must exist in every Java application? (a) main (b) paint (c) begin (d) init 26. Which of the following statements is (are) true about the use of an asterisk (*) in a Java import statement? I .It does not incur run-time overhead. II .It can be used to import multiple packages with a single statement. III .It can be used to import multiple classes with a single statement. (a) I, II, and III (b) III only (c) I only (d) I and III only 27. What will be output when the following Java program segment is executed? int x = 5; int y = 2; System.out.println(x + y); (a) 5 2 (b) 5+2 (c) 7 (d) 52 28. What is the name of the JDK program that processes Javadoc comments? (a) java (b) javac (c) javacom (d) javadoc 29. A tool that allows programmers to execute lines of a program one line at a time in order to help locate the source of a programs errors is known as a(n) (a) scope (b) exception handler (c) debugger (d) stack trace 30. UML class diagrams can describe which of the following? I .The internal structure of classes II .Relationships between classes (a) I only (b) I and II (c) II only (d) None 31. When using a debugger to step through a program, if the current line contains a method call, which of the following executes the current line and then stops execution before executing the first line in the called method? (a) step return (b) resume (c) step into (d) step over 32. According to Javadoc convention, the first sentence of each Javadoc comment should be (a) a summary sentence of the declared entry (b) an author tag (c) the order of lines is not important (d) an version tag 33. According to the Java code conventions, files longer than _ lines should be _. (a) 100, encouraged (b) 100, avoided (c) 2000, encouraged (d) 2000, avoided 34. As an aid in debugging a program in Java, print statements may be used to display which of the following types of information?I .The names of methods being called II .The values of the parameters of a method III .The values of the instance variables of a class (a) II and III only (b) I and III only (c) I and II only (d) I, II, and III 35. In a UML diagram, a specialization/generalization relationship is characterized by a line between two classes and a _ next to the _ class. (a) triangle, generalization (b) triangle, specialization (c) diamond, specialization (d) diamond, generalization 36. Consider the following Java program segment.PrintWriter fileOut = new PrintWriter( new FileWriter(output.txt);If the file output.txt already exists, which of the following events will occur when the program segment is executed? (a) The existing contents of output.txt will be preserved. (b) The existing contents of output.txt will be erased. (c) A FileAlreadyExists exception will be raised. (d) A run-time error will be generated. 37. If a class contains a constructor, that constructor will be invoked (a) once at the beginning of any program that uses that class (b) once the first time an object of that class is instantiated (c) each time an object of that class is instantiated (d) each time an object of that class goes out of scope 38. When a subclass defines an instance method with the same return type and signature as a method in its parent, the parents method is said to be (a) overloaded (b) hidden (c) overridden (d) private 39. Consider the following UML class diagram. Which of the following kinds of associations is not indicated by the class diagram? (a) One-to-one (b) One-way (c) Binary (d) Specialization/generalization 40. Regarding the following declaration, what is the index of the element containing 45?int numbers = -1, 45, 6, 132; (a) 45 (b) 0 (c) 1 (d) 2 41. Which of the following statements is not true of the class java.util.Vector? (a) An instance of Vector can store any object whose class descends from java.lang.Object. (b) Once an object is inserted into an instance of Vector, it can never be removed. (c) The constructor of the Vector class, when called with no arguments, causes an empty vector to be constructed. (d) Items stored by an instance of Vector can be accessed using integer indexes. 42. Which of the following statements is (are) true about any abstract method in Java? I .It contains no definition. II .It cannot be declared public. (a) II only (b) None (c) I only (d) I and II 43. Which is the Java keyword that denotes the use of an interface? (a) implements (b) extends (c) interface (d) import 44. A design pattern is typically used to (a) reduce the number of classes in the design of a program (b) describe a practical solution to a common design problem (c) allow the use of object-orientated concepts in a language that is not object-oriented (d) ensure that code executes at optimal speed during runtime 45. Which of the following is true of the Singleton design pattern? (a) It ensures that the methods of a class are called by only one other class. (b) It ensures that only one instance of a class is created. (c) It describes classes that have only one method. (d) It describes classes that have only one instance variable. 46. In which of the following design patterns is a family of algorithms encapsulated into individual but interchangeable classes? (a) Decorator (b) Singleton (c) Strategy (d) Proxy 47. Consider the following UML class diagram. Which of the following may be substituted for X in the above diagram to represent a multiplicity between A and B? I. 1 II. 0.* III. 1.* (a) I, II, and III (b) III only (c) II and III only (d) I and II only 48. Which of the following is true regarding the controller part in the Model-View-Controller (MVC) paradigm? (a) The controller is the abstract domain knowledge of an application. (b) The controller is the way in which the abstract domain knowledge of an application is presented to the user. (c) The controller is the list of abstract classes in an application. (d) The controller is the automatic mechanism by which the user interface is displayed and by which events are communicated between the model and the view. 49. In Java, the default layout manager for a JPanel component is (a) FlowLayout (b) GridBagLayout (c) BorderLayout (d) GridLayout 50. In Java, the default layout manager for a JFrame component is (a) GridLayout (b) BorderLayout (c) FlowLayout (d) GridBagLayout 51. Which of the following is (are) true regarding containers and components in the context of java GUI? I .A container can be added to a component. II .A component can be added to a container. III .A container can be added to another container. (a) II and III only (b) I and III only (c) I and II only (d) I, II, and III 52. Which of the following streams typically correspond(s) to screen output? I. System.in II. System.out III. System.err (a) III only (b) I, II, and III (c) II and III only (d) II only 53. Which of the following lines follow(s) Suns guidelines for documenting input parameters in a Javadoc comment? I. * param foo the value to be tested II. * param int foo III. * param the value to be tested (a) I only (b) None (c) III only (d) II only 54. Which of the following is a Java event that is generated when the close button on a JFrame component is pressed? (a) DisposeEvent (b) WindowEvent (c) ExitEvent (d) CloseEvent 55. Which of the following is (are) true regarding event handling in Java? I .When a GUI component is created, the component automatically has the ability to generate events during user interaction. II .Each Listener object must be registered with the specific component object or objects for which the Listener object is to respond. (a) II only (b) I and II (c) I only (d) None 56. Which of the following is a Java event that is generated when a JButton component is pressed? (a) ButtonEvent (b) ActionEvent (c) WindowEvent (d) ClickEvent 57. Which of the following follow(s) Suns naming conventions for Java methods? I. getValue(); II. GetValue(); III. GET_VALUE(); (a) I and II only (b) I only (c) II only (d) I, II, and III 58. In Java, what is the signature of the method in the WindowListener interface where code is to be added to end a program when the close button is pressed? (a) void windowClosed (WindowEvent we) (b) void windowAdapter (WindowEvent we) (c) void windowClosing (WindowEvent we) (d) void windowDeactivated (WindowEvent we) 59. Which of the following identifiers follow(s) Suns naming conventions for Java constants? I. START_DATE II. Serving_Size III. AnnualFee (a) I, II, and III (b) I only (c) I and II only (d) I and III only60. The ActionEvent class and ActionListener interface are available in the _ package of Java. (a) java.awt.event (b) javax.event (c) java.event (d) javax.swing.event 61. Consider the following Java program segment.String str = Three,Two,One;for (int i = 0; i str.length; +i) System.out.println(stri+/);What will be output upon execution of the program segment? (a) Three/Two/One/ (b) Three,Two,One (c) One,Two,Three (d) One/Two/Three/ 62. Regarding the following declaration, what is the index of the element containing 45? int numbers = -1, 45, 6, 132; (a) 2 (b) 0 (c) 45 (d) 1 63. In Java, which of the following can appear in abstract classes but not in interfaces? I. Definitions of instance variables II. Implementation of methods III. Implementation of constructors (a) II and III only (b) I and II only (c) I, II, and III (d) I only 64. If a file opened for reading does not exist, which of the following events will occur in Java? (a) A NullPointerException will be raised. (b) A run-time error will occur. (c) A FileNotFoundException will be raised. (d) A new file will be created. 65. In Java, the default layout manager for a JFrame component is (a) GridLayout (b) FlowLayout (c) GridBagLayout (d) BorderLayout 66. In singleton classes, the constructor is _ to ensure that instantiation is controlled through a(n) _ method. (a) omitted, static (b) private, instance (c) private, static (d) omitted, instance 67. The model part of the Model-View-Controller (MVC) paradigm embodies the (a) abstract do
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年洪江市法院系统招聘真题
- 2025广东韶关市南雄市司法局招聘1人模拟试卷及答案详解(夺冠系列)
- 2025江苏省退役军人事务厅直属优抚医院招聘12人考前自测高频考点模拟试题及完整答案详解一套
- 2025内蒙古省际劳务协作招聘岗位考前自测高频考点模拟试题及答案详解(典优)
- 2025杭州医学院招聘1人考前自测高频考点模拟试题及答案详解(易错题)
- 2025广西科技大学招聘附属医院(临床医学院)领导干部3人模拟试卷及参考答案详解一套
- 2025年双门轿跑车合作协议书
- 2025河南新乡育才高级中学新乡市育才实验学校招聘70人考前自测高频考点模拟试题及答案详解一套
- 2025广西河池市计量测试研究所招聘工作人员2人模拟试卷(含答案详解)
- 2025广西玉林容县公安局第一次公开招聘警务辅助人员23人考前自测高频考点模拟试题及答案详解(名校卷)
- 家园2-菲雅利帝国全贸易模式全商品
- 四级词汇熟词僻义表
- D500-D505 2016年合订本防雷与接地图集
- 吊装作业危险源辨识与风险评价
- YS/T 643-2007水合三氯化铱
- 幼儿成长档案电子通用版
- Linux操作系统课件(完整版)
- 短视频:策划+拍摄+制作+运营课件(完整版)
- 首都师范大学本科生重修课程自学申请表
- 第四章路面施工.ppt
- mr9270s文件包中文说明书
评论
0/150
提交评论