问题 单项选择题

下面程序段的输出结果是( )。 classBase { inti; Base() { add(1); } voidadd(intV) { i+=v; } Voidphnt() { System.out.println(i); } } Class EXtenSiOneXtendSBaSe { ExtensiOn() { add(2); } voidadd(int v) { i+=v*2; } } public class TeSst { publicstatic voidmain(String argS[]) { bogo(new Extension()); } Static voidbogo(Base b) { b.add(8); b.phnt(); } }

A.9

B.18

C.20

D.22

答案

参考答案:D

解析: 本题考查继承和构造函数的用法。首先要明确对一个类的继承是指在父类的基础上构建了一个子类,子类继承了父类的方法和状态。题目所给程序段创建的是Extension类的实例,在运行时,从main()函数进入程序,所有调用add()方法的过程将始终和Extension类的add()方法动态绑定。初始值:i=0:创建实例newExtension();先调用父类的默认构造函数 Base(),并在父类的默认构造函数中执行ada(1),i=0+1×2,所以i=2,再调用子类的默认构造函数Extension(),子类的默认构造函数中执行add(2),i=2+2×2,所以i=6;执行add(S):i=6+8×2,因此,最终i=22,正确答案为选项D。

填空题
阅读理解

In America, when the eighth graders leave the middle school, they are often worried about moving to the high school. It is a hard time for them,but it can be an exciting one as well. To make it easier, students need to get familiar with their school.

Even though they’ve done this already in the middle school, it’s still important to find where their classrooms are. Most schools take students to the high school for a visit at the end of their eighth grade year. And, most schools also have a freshman (新生) speech for parents and students before the first year begins. Sometimes the main office will give away a map of the school. This can help students and parents to find different places in the school.

One way to know your high school more and make new friends is to join a club or play a sport.Schools often offer chances to join different clubs and sports. Fall activities begin in August before the first day of school. If you are not interested in sports, there are clubs for any interest, such as drama, dance, chess, photography, community service, etc. These clubs allow students from different grades. By joining an activity, students can find new friendships, not to mention improving their chances in future college applications(申请). The school office will have a list of activities offered at the school and information on how to join them.

What’s more, to have a great start to a high school year, students can write down some of their worries, and ask for help from teachers and school workers.

小题1:According to the text, most students feel ________ when entering the high school.

A.unhappy

B.nervous

C.lonely

D.disappointed小题2:Which of the following is TRUE about the school clubs?

A.There are fewer students from higher grades in the school clubs.

B.The school clubs in high school mainly welcome sports fans.

C.Summer activities begin before school starts.

D.School officers can help new students join school clubs.小题3:When do many schools take students to visit their new high school?

A.Before the eighth grade year starts.

B.Right after the high school year starts.

C.At the beginning of the new term in the high school.

D.By the end of the last year in the middle school.小题4:What is the purpose of this text?

A.To describe high school life.

B.To introduce new schools.

C.To teach useful experience.

D.To give advice to new high school students.