问题 单项选择题

以下关于子类和父类的叙述中,正确的是()。

A.代码中使用父类对象的地方,都可以使用子类对象替换

B.代码中使用子类对象的地方,都可以使用父类对象替换

C.父类定义的对象与子类定义的对象在属性和方法上一定相同

D.父类定义的对象与子类定义的对象在属性和方法上一定不同

答案

参考答案:A

解析:

本题考查类和对象的基本概念。

面向对象技术中,子类是父类的特化,子类可以根据自己的需求,选择和父类保持一样的属性和方法,或者增加新的属性、方法,或者改变父类已有的方法。但根据类之间继承关系的含义,一个子类对象一定也是一个父类对象,所有使用父类对象的地方,都可以使用子类对象代替。因为子类可以选择改变父类的属性和方法,因此,子类和父类有可能具有完全相同的属性和方法,也有可能不完全相同。

完形填空
Do you want to be successful in everything you do? If so, then      _? Here is an example.
There was a farmer who      _ corn (玉米) all his life. Each year he took his corn to the market. Then each time his corn was chosen as the _     and won the first prize.
One year a newspaper reporter interviewed him and learned something surprising about how he grew it.The farmer _     seed (做种子的) corn to his neighbors.
“How can you share your best seed corn with your neighbors?” the reporter asked.“You know they are taking part in the _     with you each year.”
“Why, sir,” said the farmer, “didn't you know?The wind picks up pollen (花粉) from the corn and moves it quickly from field to field. If my neighbors grow      __ corn, cross­pollination (异花传粉) will affect the quality of my corn. So if I want to grow good corn, I must _    _ my neighbors to grow good corn.”
The farmer knows much about the connection of life. His corn cannot improve _    _ his neighbor's corn improves.
As a great man says, “We make a living by what we __    _, but we make a life by what we give.” We can't live without food, clothes, and many other things. However, a meaningful life is not decided by how much we can get, but by how much we can give others. Giving, instead of taking, makes us different from other animals. So those who choose to live well must help others to live well and those who choose to be happy must help others to find _    _ in their life.
小题1:
A.whyB.howC.whenD.where
小题2:
A.grewB.boughtC.soldD.collected
小题3:
A.cheapestB.prettiestC.bestD.shortest
小题4:
A.lentB.showedC.offeredD.provided
小题5:
A.gameB.fightC.experimentD.competition
小题6:
A.tastyB.badC.tallD.unusual
小题7:
A.teachB.remindC.helpD.require
小题8:
A.unlessB.thoughC.becauseD.when
小题9:
A.doB.ownC.getD.grow
小题10:
A.hopeB.successC.friendshipD.happiness
单项选择题