问题 选择题

(2013·山西高三诊断)—Oh, God! Somebody ________ the cup.

—It wasn't me. I didn't do it.

A.was breaking

B.is breaking

C.has broken

D.had broken

答案

答案:C

C 考查时态。句意:“啊,天呀!有人把杯子打碎了。”“不是我,我没有打碎它。”根据答语可知,杯子被人打碎发生在过去,且对现在造成了一定的影响,故应用现在完成时。C项正确。

问答题

【说明】
某绘图系统存在point、line、square三种图元,它们具有Shape接口,图元的类图关系如图13-12所示。现要将circle图元加入此绘图系统以实现功能扩充。已知某第三方库已经提供了XCircle类,且完全满足系统新增的Circle图元所需的功能,但XCircle不是由 Shape派生而来的,它提供的接口不能被系统直接使用。代码13-2既使用了XCircle又遵循了Shape规定的接口,既避免了从头开发一个新的Circle类,又可以不修改绘图系统中已经定义的接口。代码13-3根据用户指定的参数生成特定的图元实例,并对之进行显示操作。绘图系统定义的接口与XCircle提供的显示接口及其功能如表13-5所示。
表13-5接口及其功能

Shape XCircle 功能
display() DisplayIt() 显示图元


【代码13-2】
class Circle (1)
private (2) pxc;
public Circle()
pxc=new (3)

public void display()
pxc. (4)
【代码13-3】
public class Factory
public (5) getShape Instance(int tyoe) //生成特定类实例
switch(type)
case 0: return new point();
case 1: return new Rectangle();
case 2: return new line();
case 3: return new Circle();
default: return null


;
public class App
public static viod main(String argv[

)
if(argv. length!=1)
system. out. println("error parameters!");
Return;

int type=(new Integer(argv[0

)). intValue();
Factory factory=new Factory();
shape s;
s=factory. (6) ;
if(s==null)
system.out. println("Error get instance!");
Return;

s.display();
return;

单项选择题