1. Which of the following statements about java classes is (are) accurate?
i. a class may have only one parent.
ii. two or more classes may share a parent.
A. i and ii
B. none
C. i only
D. ii only
Correct Answer: A
2. 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. none
B. ii only
C. i and ii
D. i only
Correct Answer: D
3. A design pattern is typically used to
A. ensure that cpde executes at optimal speed during runtime.
B. reduce the number of classes in the design of a program.
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 problem.
Correct Answer: D
4. 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 only
B. ii only
C. none
D. i and ii
Correct Answer: D
5. 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. ii only
B. none
C. i and ii
D. i only
Correct Answer: D
6. Consider the following definition of a java class.
public class C {
private static c instance = null;
private C() {}
public static C getInstance() {
if (instance == null) {
instance = new C();
}
return C;
}
}
this class is an example of the design pattern
A. singleton
B. strategy
C. adapter
D. decorator
Correct Answer: A
7. 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 that one interface
A. ii only
B. none
C. i and ii
D. i only
Correct Answer: A
8. 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. i only
B. ii only
C. none
D. i and ii
Correct Answer: D
9. The subclass of an abstract class must
A. be abstract and implement all of the parent's abstract methods
B. implement all of the parent's abstract methods
C. be abstract
D. be abstract pr implement all of the parent's abstract methods
Correct Answer: D
10. Which of the following statements is(are) true in java?
i. all of the methods in an abstract class must be abstract.
ii. all of the methods in an interface must be abstract.
A. none
B. i and ii
C. i only
D. ii only
Correct Answer: D
(部分题目来自网络,如有侵权,请联系文章作者删除)