装饰(Decorator)模式的主要优点有()
A.采用装饰模式扩展对象的功能比采用继承方式更加灵活
B.可以设计出多个不同的具体装饰类,创造出多个不同行为的组合
C.客户端可以透明地调用目标接口
D.复用了现存的类,程序员不需要修改原有代码
AB
A.采用装饰模式扩展对象的功能比采用继承方式更加灵活
B.可以设计出多个不同的具体装饰类,创造出多个不同行为的组合
C.客户端可以透明地调用目标接口
D.复用了现存的类,程序员不需要修改原有代码
AB
第1题
试题六(共15分)
阅读下列说明和Java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。
【说明】
某发票(lnvoice)由抬头(Head)部分、正文部分和脚注(Foot)部分构成。现采用装饰(Decorator)模式实现打印发票的功能,得到如图6-1所示的类图。
【java代码】
class invoice{
public void printInvoice(){:
System.out.println ("This is the content of the invoice!");
}
}
class Decorator : extends Invoice {
protected Invoice ticket;
public Decorator(lnvoice t){
ticket = t;
}
public void printinvoice(){
if(ticket != NULL)
(1);
}
}
class FootDecorator extends Decorator{
public FootDecorator(lnvoice t){
super(t);
}
public void printinvoice (){
Systent.out.println("This is the header of the invoice! ");
(2) ;
}
}
class FootDecorator extends Decorator {
public FootDecorator(invoice t):{
super(t);
}
public void printlnvoice(){
(3) ;
Systent.out.println("This is the header of the invoice! ");
}
}
Class test {
public static void main(string[] args){
Invoice t =new invioce();
Invoice ticket;
Ticket= (4) ;
Ticket. Printinvoice();
Systent.out.println(“--------------“)
Ticket= (5) ;
Ticket. Printinvoice();
}
}
程序的输出结果为:
This is the header of the invoice!
This is the content of the invoice!
This is the footnote of the invoice!
----------------------------
This is the header of the invoice!
This is the footnote of the invoice!
第2题
A.外观
B.单体
C.装饰
D.模板方法
第4题
A.直观易懂,对维护人员技术要求低
B.主要起装饰作用,产品外观美观,具有个性
C.若产品自身出现故障,可-键恢复网络,减轻单点故障对业务的影响
D.方便管理员进行网络故障定位,快速判断是上网行为管理的问题还是其它网络设备的问题
第5题
A.业主
B.R监理公司
C.G施工企业
D.施工总承包管理方
第6题
A.整合了联邦制的主要优点
B.整合了中西政体和文化精神
C.发展了联邦政体的柔性特征
D.继承了传统政体和文化精神
第7题
A.虚拟化
B.软件即服务
C.资源无限
D.分布式计算
第8题
A.从价值工程角度可以取得明显的经济效果
B.承包范围大,竞争不激烈
C.可以提高项目的经济性
D.从全寿命费用的角度可以取得明显的经济效果
E.合同总价较低
第9题
A.虚拟化
B.软件即服务
C.资源无限
D.分布式计算
第10题
A.虚拟化
B.软件即效劳
C.资源无限
D.分布式计算