好文档 - 专业文书写作范文服务资料分享网站

java单选题版 doc

天下 分享 时间: 加入收藏 我要投稿 点赞

The class java.util.ArrayList implements a collection that (a) can only store primitive variables such as int or boolean (b) can grow to accommodate new items

(c) cannot be accessed using an integer index

(d) can only store instances of the class java.lang.String Correct answer is (b) 67.

In which of the following ways can items be added to a collection implemented by java.util.ArrayList?

1. Items can be inserted at the beginning of the collection.

2. Items can be inserted between two existing items in the collection. 3. Items can be appended to the end of the collection. (a) III only

(b) I and III only (c) I only

(d) I, II, and III

Correct answer is (d) 68.

An object that contains methods that traverse a collection linearly from start to finish is known as a(n) (a) Exception (b) int (c) loop (d) iterator

Correct answer is (d) 69.

Which of the following statements is not true of the class java.util.ArrayList?

(a) The constructor of the ArrayList class, when called with no arguments, causes an empty ArrayList to be constructed.

(b) An instance of ArrayList can grow to accommodate new items when the collection is full.

(c) Once an object is inserted into an instance of ArrayList, it can never be removed. (d) Items stored by an instance of ArrayList can be accessed using integer indexes. Correct answer is (c) 70.

Consider the following Java program segment. int[] arr;

arr = new int[3]; arr[2]=19; arr[1]=17; arr[0]=15;

Which of the following Java statements is syntactically correct and semantically identical to the program segment? (a) int[] arr= {15, 17, 19}; (b) int arr[3]= {15, 17, 19}; (c) int[3] arr = {15, 17, 19}; (d) int arr = {15, 17, 19}; Correct answer is (a) 1.

Which of the following statements is (are) true about any abstract metho d in Java?

I. It contains no definition.

II. It cannot be declared public.

(a) I only (b) II only (c) I and II (d) None

Correct answer is (a) 2.

Which of the following statements is (are) true in Java?

I. Classes that contain abstract methods must be declared abstract. II. Classes that contain protected methods must be declared abstrac t.

(a) I and II (b) None (c) I only (d) II only

Correct answer is (c) 3.

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 II. An object of class Vehicle

(a) I and III only (b) II and III only (c) III only

(d) I, II, and III

Correct answer is (a) 4.

Which of the following statements is (are) true about interfaces in Jav a?

I. Interfaces can extend other interfaces. II. Interfaces can contain data fields.

(a) I and II (b) None

(c) II only (d) I only

Correct answer is (a)

5. Data fields in an interface implicitly have _____ access in Java.

(a) private (b) abstract (c) public (d) protected

Correct answer is (c) 6.

Which of the following statements is (are) true in Java? I. An abstract class may contain data fields. II. Interfaces may contain data fields.

(a) I and II (b) None (c) II only (d) I only

Correct answer is (a)

7. In Java, all methods in an interface must be _____ and _____.

(a) private, abstract (b) public, static (c) public, abstract (d) static, private

Correct answer is (c)

8. A design pattern is typically used to

(a) allow the use of object-orientated concepts in a language that is not object-oriented

(b) ensure that code executes at optimal speed during runtime (c) describe a practical solution to a common design problem (d) reduce the number of classes in the design of a program Correct answer is (c) 9.

The constructor of a class that adheres to the Singleton design pattern must have _____ visibility.

(a) package (b) protected (c) private (d) public

Correct answer is (c) 10.

In which of the following design patterns is a family of algorithms enca psulated into individual but interchangeable classes?

(a) Singleton(b) Decorator (c) Strategy (d) Proxy

Correct answer is (c)

------------------------------------------------------------------------------------------- 11.

A relationship that exists between two specific instances of an object is known as a(n)

(a) specialization (b) link

(c) aggregation (d) association

Correct answer is (b)

--------------------------------------------------------------------------------

12.

Which of the following is true about association and aggregation in UML class diagrams?

(a) Association and aggregation have no meaningful relationship. (b) Association is the opposite of aggregation. (c) Aggregation is a special form of association. (d) Association is a special form of aggregation.

Correct answer is (c)

13.

A binary association is said to exist between two classes when

(a) an object of one class requires an object of the other class (b) one class is a subtype of the other class

(c) one class belongs to the same package as the other class

(d) an object of one class is instantiated in the same method as an object of the other class

Correct answer is (a) --------------------------------------------------------------------------------

14.

When using noun-phrase analysis to model a software system, which of the following should typically be eliminated from the list of potential classes?

References to the software system itself Nouns that imply roles between objects Synonyms to other nouns in the list

(a) I and III only (b) III only

(c) II and III only (d) I, II, and III

Correct answer is (d)

--------------------------------------------------------------------------------

15.

The static model of a software system typically includes which of the following?

Attributes of classes

Actions that occur between classes

Structural relationships between classes

(a) I, II, and III (b) II and III only (c) I and III only (d) I and II only

Correct answer is (c)

1. Given the following code, how many tokens will be output? (b) StringTokenizer st = new StringTokenizer(\ while (st.hasMoreTokens()) {

stdOut.println(st.nextToken() ); }

(a) 1 (b) 4 (c) 0 (d) 3 1. Consider the following UML class diagram.

According to the diagram, instances of the class named _____ have references to instances of

the class named _____. (a) (a) A, B (b) A, C (c) B, A (d) B, C

2. Consider the following UML class diagram.

According to the diagram, which of the following statements is true? (a)

(a) ClassA is composed of one instance of ClassB and one or more instances of ClassC. (b) ClassB and ClassC are both subclasses of ClassA.

(c) ClassB has a one-to-one association with ClassA and a one-to-many association with

ClassC.

(d) ClassA and ClassB each contain at least one reference to an instance of ClassC. 4. The multiplicity of an association between two classes indicates the number of (a) (a) instances of one class that can be associated with an instance of the other class (b) methods of one class that are called by the other class (c) methods and variables common to both classes

(d) times that one class's methods are called by the other class 1. A collection typically models a _____ relationship. (b) (a) many-to-many (b) one-to-many (c) zero-to-one (d) one-to-one

2. Consider the following UML class diagram. (c)

The diagram describes a

(a) relationship between a subclass and a superclass

java单选题版 doc

Theclassjava.util.ArrayListimplementsacollectionthat(a)canonlystoreprimitivevariablessuchasintorboolean(b)cangrowtoaccommodatenewitems(c)cannotbeaccessedusing
推荐度:
点击下载文档文档为doc格式
8ao7g9bfhr00kc5204u903ypi6bk1500j2g
领取福利

微信扫码领取福利

微信扫码分享