问题 单项选择题

以下关于面向对象的叙述中,说法正确的是()。

A.对象间的连接必须绑定到一个具体类的对象上

B.针对实现编程,而不是针对接口编程

C.优先使用继承而非组合

D.客户无须知道特定类,只需知道他们所期望的接口

答案

参考答案:D

解析:

[要点解析] 面向对象的设计原则之一是:针对接口编程,而不是针对实现编程。针对接口编程能够将接口调用代码和接口实现代码相分离。遵循这个原则的好处有:①客户不必知道其使用对象的具体所属类;②客户无须知道特定类,只需知道他们所期望的接口;③一个对象可以很容易地被实现了相同接口的另一个对象所替换;④对象间的连接不必硬绑定到一个具体类的对象上,灵活性高;⑤增加了重用的可能性,提高了对象组合的机率;⑥松散耦合。

阅读理解

阅读理解。

     One of my favorite posters says, "Life is a test. It is only a test. Had this been a real life, you would have

been instructed where to go and what to do." Whenever I think of this humorous bit of wisdom, it reminds

me not to take my life so seriously.

     When you look on life and its many challenges as a test, or series of tests, you begin to see each issue you

face as an opportunity to grow, a chance to discover more about life. Whether you're being bombarded with

problems, responsibilities, or even insurmountable (不能超越的) difficulties, when looked on as a test, you

always have a chance to succeed, in the sense of overcoming what is challenging you. If, on the other hand,

you see each new issue you face as a serious battle that must be won in order to survive, you're probably

meeting with a very rocky journey. The only time you're likely to be happy is when everything is working out

just right. And we all know how often that happens.

     As an experiment, see if you can apply this idea to something you are forced to deal with. Perhaps you

have much pressure from your parents or you have a demanding boss. See if you can redefine the issue you

face from being a "problem" to being a test. Rather than struggling with your issue, see if there is something

you can learn from it. Ask yourself, "Why is this an issue in my life? What would it mean and what would be

involved to overcome it? Could I possibly look at this issue any differently? Can I see it as a test of some kind?" 

     If you give this strategy (策略) a try, you may be surprised at your changed responses. It has become far

more acceptable to me to accept things as they are.

1. When you begin to look on life as a test, you will find ____.

A. you are bombarded with problems and responsibilities

B. you're meeting with a very rocky journey

C. you have many opportunities to grow

D. you have to go to school to take tests every day

2. When you see each new issue as a serious battle, you ____.

A. will have more chances to succeed

B. are likely to become happy all your life

C. will know how often it happens

D. are probably to experience a bitter life

3. According to the passage, you'd better look on life as a test when ____.

A. you try to get the meaning of the poster

B. you have an easy-going boss

C. you are carrying out an experiment

D. you are in a rocky journey

4. According to the passage, what is the author's attitude towards life?

A. He considers life as a test.

B. He doesn't dare face his hard life.

C. He thinks life is full of humorous wisdom.

D. He thinks life is not only a test but also a serious battle.

单项选择题