Java&OOP基础知识英文选择题7——Inheritance, Abstract class, Design Pattern

本文通过问答形式探讨了Java中关于类、抽象方法、设计模式、继承、接口等核心概念的理解,并提供了正确的答案选项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

(部分题目来自网络,如有侵权,请联系文章作者删除)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值