首页
登录
从业资格
阅读下列说明和java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。
阅读下列说明和java代码,将应填入 (n) 处的字句写在答题纸的对应栏内。
免费题库
2022-08-02
7
问题
阅读下列说明和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;} publicvoid printInvoice( ){ if(ticket != null) (1) ; } }class HeadDecorator extends Decorator{ public HeadDecorator(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 footnote 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!
选项
答案
解析
(1) ticket.printInvoice()
(2) ticket.printInvoice()
(3) ticket.printInvoice()
(4) new FootDecorator(new
转载请注明原文地址:https://tihaiku.com/congyezige/2407733.html
本试题收录于:
中级 软件设计师题库软件水平考试初中高级分类
中级 软件设计师
软件水平考试初中高级
相关试题推荐
( )是蠕虫病毒。A.熊猫烧香 B.红色代码 C.冰河 D.爱虫病毒
软件测试的对象包括( )。 ①软件代码使②文档③数据A.①②
传统编译器进行词法分析、语法分析、代码生成等步骤的处理时,前一阶段处理的输出是后
传统编译器进行词法分析、语法分析、代码生成等步骤的处理时,前一阶段处理的输出是后
软件测试的对象不包括()。A.一段功能的实现代码 B.概要设计说明书 C.
软件测试的对象不包括()。A.软件代码 B.软件文档 C.质量保证方法
()属于系统软件,它直接执行高级语言源程序或与源程序等价的某种中间代码。A.
关于软件测试的说法,()是不正确的。A.代码审查是代码检查的一种,是由
软件测试的对象不包括()A.软件代码 B.软件开发过程 C.文档 D.数
以下属于静态测试方法的是_____。A.代码审查 B.判定覆盖 C.路径覆盖
随机试题
"Congratulations,Mr.Cooper.It’sagirl."Fatherhoodisgoingtohave
Dothebenefitsofstudyabroadjustifythedifficulties?Theideaofgoing
He______inhischildhood,andtheygotmarriedwhentheygrewup.A、madetheacqu
CorporateCrimeOverdecadesofyears,corporatecrimehasbeen【T1】______in
Whataretwokindsofbusinessesthatsometimeshavesmallstaffs?______orman
防渗帷幕的防渗标准根据坝型、坝高确定。对于重力坝和拱坝,防渗帷幕幕体及其下部岩体
桥梁结构检算应针对结构主要控制截面、薄弱部位和出现严重缺损部位。()
为了番茄红素的摄入,西红柿最好的烹饪手段是?A.生吃 B.煮汤 C.煎炒
子痫的发生常见于产后。
新时代必须坚持()的发展思想,不断促进人的全面发展、全体人民共同富裕。A.以经济
最新回复
(
0
)