记几道java期末考试选择题

1.  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.

Class variables require the modifier static in the declarations.

 

C.

All objects have their own copy of the class variable defined in the instantiated class.

 

D.

Class variables do not need the reference to the object of the instantiated class to access them.

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

A.

public


B.

private

C.

package

D.

protected



1. The subclass of an abstract class must

A.

 be abstract or implement all of the parent's abstract methods

B.

be abstract


C.

be abstract and implement all of the parent's abstract methods

D.

implement all of the parent's abstract methods


1.  The Strategy design pattern is likely to be useful when implementing which of the following?

I. An application that offers several alternate sorting algorithms

II. A simple class to store the address of an organization of which only one instance can be instantiated

A.

I and II

B.

None

C.

II only


D.

I only


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

I. Attributes of classes

II. Actions that occur between classes

III. Structural relationships between classes

A.

I, II, and III

B.

I and II only


C.

I and III only

D.

II and III only


1.  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.

III only


C.

 I, II, and III

D.

II and III only


1. If a class has an association with itself, then the class contains

A.

its own superclass

B.

an attribute that references an object of the same class

C.

a method that calls itself

D.

a method that calls another method within the same class


1. 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 is instantiated in the same method as an object of the other class

C.

one class is a subtype of the other class

D.

an object of one class requires an object of the other class



1. A collection typically models a _____ relationship.

 

A.

many-to-many

 

B.

zero-to-one


C.

one-to-many

 

D.

one-to-one


1. If a class contains a constructor, that constructor will be invoked


A.

each time an object of that class is instantiated

B.

each time an object of that class goes out of scope

C.

once the first time an object of that class is instantiated

D.

once at the beginning of any program that uses that class



猜你喜欢

转载自blog.csdn.net/qq_41686190/article/details/80908981