Java英文题.doc_第1页
Java英文题.doc_第2页
Java英文题.doc_第3页
Java英文题.doc_第4页
Java英文题.doc_第5页
已阅读5页,还剩8页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Multiple-Choice1. The name of a Java source file (a) has no restrictions(b) must be the same as the class it defines, ignoring case(c) must use the extension .class(d) must be the same as the class it defines, respecting case2. Which of the following statements is (are) true about the use of an asterisk (*) in a Java import statement? .It does not incur run-time overhead. .It can be used to import multiple packages with a single statement. .It can be used to import multiple classes with a single statement(a) I, II, and III(b) I and III only(c) I only(d) III only3. What is the name of the wrapper class for the type int? (a) INT (b) integer (c) Integer (d) Int4. A difference between the methods print and println of the class java.io.PrintWriter is that (a) println inserts a new line at the beginning of its output, but print does not (b) print inserts a new line at the beginning of its output, but println 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 not5. 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 512.(b) The output caused by the code will be 5 1 2.(c) The output caused by the code will be 8.(d) The code will cause a compilation error.6. All Java exception classes are derived from the class (a) java.lang.RuntimeException (b) java.lang.Throwable (c) java.lang.Error (d) java.io.IOException7. What is the right way to handle abnormalities in input on Java? (a) By writing while loops to guard against bad input (b) By handling these problems by providing exception handlers (c) By using the class FileFilter which gracefully filters out bad input data (d) By always specifying the throws clause in every method header where file I/O is performed8. Which of the following patterns of characters opens a Javadoc comment block? (a) /* (b) */ (c) /* (d) /9. According to the Java code conventions, files that contain Java source code have the suffix _, and compiled bytecode files have the suffix _. (a) .class, .java (b) .class, .javac (c) .java, .class (d) .javac, .class10. 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 . The values of the instance variables of a class(a) I and II only (b) I and III only(c) II and III only (d) I, II, and III1. In a UML class diagrams representation of a class, the top, middle, and lower rectangular compartments respectively describe the _ of the class. (a) name, attributes, and methods (b) name, methods, and constants(c) attributes, methods, and name (d) attributes, methods, and constants2. UML class diagrams can describe which of the following? I. The internal structure of classes . Relationships between classes(a) I and II (b) II only (c) None (d) I only3. Consider the following UML class diagram. According to the diagram, instances of the class named _ have references to instances of the class named _. (a) B, A (b) A, C (c) B, C (d) A, B4. Which of the following is true about association and aggregation in UML class diagrams? (a) Association is the opposite of aggregation. (b) Aggregation is a special form of association. (c) Association is a special form of aggregation. (d) Association and aggregation have no meaningful relationship.?5. A binary association is said to exist between two classes when (a) one class belongs to the same package as the other class (b) an object of one class requires an object of the other class (c) an object of one class is instantiated in the same method as an object of the other class (d) one class is a subtype of the other class6. Consider the following UML class diagram. According to the diagram, which of the following statements is (are) true? I. ClassB is a specialization of ClassA. II. ClassA is a generalization of ClassC. . ClassC is involved in a self-containment loop. (a) II and III only (b) I and II only (c) I, II, and III (d) I and III only7. A collection typically models a _ relationship. (a) one-to-one (b) many-to-many (c) zero-to-one (d) one-to-many8. Consider the following UML class diagram. Which of the following is (are) true about the system described by the diagram? I. An instance of Picture can contain a collection of instances of the class Shape. . An instance of Shape can contain a collection of instances of the class Picture.(a) II only (b) None (c) I only (d) I and II9. 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 . Synonyms to other nouns in the list(a) II and III only (b) I and III only(c) III only (d) I, II, and III10. The static model of a software system typically includes which of the following? I. Attributes of classes II. Actions that occur between classes . Structural relationships between classes (a) I and III only (b) II and III only (c) I, II, and III (d) I and II only1.The term class variable is a synonym for (a) a private data field (b) a static data field (c) a read-only variable (d) an instance variable2. 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(d) The line of text non-default followed by the line of text default3. Which of the following categorizations can be applied to both the data fields and the methods in a Java class? (a) native and non-native(b) default and non-default(c) static and non-static(d) abstract and non-abstract4. Which of the following statements about class variables in Java is not true? (a) Class variables require the modifier static in the declarations.(b) All objects have their own copy of the class variable defined in the instantiated class.(c) Non-static methods in a class can access the class variable defined in the same class.(d) Class variables do not need the reference to the object of the instantiated class to access them.5. If a class contains a constructor, that constructor will be invoked (a) each time an object of that class goes out of scope (b) each time an object of that class is instantiated (c) once the first time an object of that class is instantiated (d) once at the beginning of any program that uses that class6. Which of the following statements about constructors in Java is true? (a) A class can define more than one constructor. (b) A constructor must be defined as public. (c) A constructor must be defined as static. (d) A class must define at least one constructor.7. 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) int sum(int x, int y) (d) float sum(int x, float y)8. 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. . Method d returns equivalent results when executed from either class. (a) I, II, and III (b) I and III only (c) III only (d) I and II only9. 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) private (b) hidden (c) overloaded (d) overridden10. Which is a Java access modifier used to designate that a particular data field will not be inherited by a subclass? (a) final (b) protected (c) private (d) default 1. 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/2. Consider the following Java program segment. int arr;arr = new int3;arr2=19;arr1=17;arr0=15;Which of the following Java statements is syntactically correct and semantically identical to the program segment?(a) int arr= 15, 17, 19;(b) int3 arr = 15, 17, 19;(c) int arr = 15, 17, 19;(d) int arr3= 15, 17, 19;3. Regarding the following declaration, what is the index of the element containing 45? int numbers = -1, 45, 6, 132; (a) 0 (b) 1 (c) 45 (d) 24Legal Java statements to initialize an array reference include which of the following? I. int aobj = 0, 1, 2; II. int4 aobj = 0, 1, 2; . int aobj = new int3;(a) I and II only (b) I only (c) III only (d) I and III only5. If the length of a particular array is the value of LIMIT, what is the index of the last item in that array? (a) LIMIT (b) LIMIT 1 (c) LIMIT / 2 (d) 06. Consider the Java program below. public class Arr public static void main(String args) int a = 1, 2, 3; System.out.println(a1); System.out.println(a3); Which of the following is true about the result of executing the program?(a) The number 1 is printed and there is no abnormal termination.(b) The number 3 is printed and a run-time exception terminates execution.(c) The number 2 is printed and there is no abnormal termination.(d) The number 2 is printed and a run-time exception terminates execution.7. In which of the following ways can items be added to a collection implemented by java.util.ArrayList? I. Items can be inserted at the beginning of the collection. II. Items can be inserted between two existing items in the collection. . Items can be appended to the end of the collection.(a) I only (b) I, II, and III (c) I and III only (d) III only8. An object that contains methods that traverse a collection linearly from start to finish is known as a(n) (a) int (b) iterator (c) loop (d) Exception9. Consider the following method call, where c is an instance of the class java.util.ArrayList. c.size();This method call returns the number of(a) times that the method c.add has been called(b) bytes used by c(c) ArrayList objects that have been instantiated(d) elements in the ArrayList represented by c10. The class java.util.ArrayList implements a collection that (a) can grow to accommodate new items (b) can only store primitive variables such as int or Boolean(c) can only store instances of the class java.lang.String(d) cannot be accessed using an integer index1. The subclass of an abstract class must (a) be abstract(b) be abstract and implement all of the parents abstract methods(c) be abstract or implement all of the parents abstract methods(d) implement all of the parents abstract methods2. Which of the following statements is (are) true about any abstract method in Java? I. It contains no definition. . It cannot be declared public. (a) I and II (b) I only (c) None (d) II only3. Consider the following Java program fragment. public void drive(Vehicle v) .drive(obj);The method call drive(obj) is valid if obj is which of the following? I. A descendent of class Vehicle II. An ancestor of class Vehicle . An object of class Vehicle (a) I and III only (b) I, II, and III (c) III only (d) II and III only4. Which of the following statements is (are) true in Java? I. An abstract class may contain data fields. . Interfaces may contain data fields.(a) I and II (b) I only (c) None (d) II only5. Which of the following statements is (are) true about interfaces in Java? I. Interfaces can extend other interfaces. . Interfaces can contain data fields.(a) I only (b) None (c) II only (d) I and II6. Which of the following statements is (are) true in Java? I. All of the methods in an abstract class must be abstract. . All of the methods in an interface must be abstract. (a) None (b) I only (c) II only (d) I and II7. Which of the following statements is (are) true about all data fields in an interface in Java? I. They are implicitly public. II. They are implicitly final. . They are implicitly static.(a) I and II only (b) I, II, and III(c) II and III only (d) II only8. A design pattern is typically used to (a) reduce the number of classes in the design of a program (b) ensure that code executes at optimal speed during runtime (c) allow the use of object-orientated concepts in a language that is not object-oriented (d) describe a practical solution to a common design problem9. The constructor of a class that adheres to the Singleton design pattern must have _ visibility. (a) public (b) protected (c) package (d) private10. The Strategy design pattern is likely to be useful when implementing which of the following? I. An application that offers several alternate sorting algorithms . A simple class to store the address of an organization of which only one instance can be instantiated (a) II only (b) I only (c) None (d) I and II1.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 erased.(b) A FileAlreadyExists exception will be raised.(c) The existing contents of output.txt will be preserved.(d) A run-time error will be generated.2. The model part of the Model-View-Controller (MVC) paradigm embodies the (a) automatic mechanism by which the user interface is displayed and by which events are communicated between the view and the controller(b) way in which the abstract domain knowledge of an application is presented to the user(c) abstract domain knowledge of an application(d) list of abstract classes in an application3. Which of the following is true regarding the controller part in the Model-View-Controller (MVC) paradigm? (a) The controller is the list of abstract classes in 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 abstract domain knowledge of 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.4. In Java, the default layout manager for a JFrame component

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论