首页
登录
从业资格
阅读下列说明和Java代码,将应填入(n)处的字句写在对应栏内。某饭店在不同的时
阅读下列说明和Java代码,将应填入(n)处的字句写在对应栏内。某饭店在不同的时
最全题库
2022-08-02
49
问题
阅读下列说明和Java代码,将应填入(n)处的字句写在对应栏内。某饭店在不同的时段提供多种不同的餐饮,其菜单的结构图如图5-1所示。
现在采用组合(Composition)模式来构造该饭店的菜单,使得饭店可以方便地在其中增加新的餐饮形式,得到如图5-2所示的类图。其中MenuComponent为抽象类,定义了添加(add)新菜单和打印饭店所有菜单信息(print)的方法接口。类Menu表示饭店提供的每种餐饮形式的菜单,如煎饼屋菜单、咖啡屋菜单等。每种菜单中都可以添加子菜单,例如图5-1中的甜点菜单。类MenuItem表示菜单中的菜式。
选项
答案
解析
(1) abstract class或public abstract class(2) public abstract void add (MenuComponent menuComponent)或abstract void add (MenuComponent menuComponent)或protected abstract void add (MenuComponent menuComponent)(3) add (menuComponent)(4) menuComponent.print ()(5) allMenus.print ()
转载请注明原文地址:https://tihaiku.com/congyezige/2424917.html
本试题收录于:
初级程序员题库软件水平考试初中高级分类
初级程序员
软件水平考试初中高级
相关试题推荐
IE浏览器能够正确解析()代码。A.ASP B.HTML C.JSP D
网页中代码"inputtype=textname="foo"size=20
在如下所示的一段XML代码中,根元素名为()。 <?xmlversion="
负责解释执行JavaScript代码的是()。A.Web服务器 B.Web浏览
下面的XML代码段中,语法正确的是()。A.<!-xml示例-!><?xml
在网页中创建Email链接,代码正确的是()。A.<ahref=“call
在html文档中,有如下代码: <form> List1:
要在HTML中按原格式输出一段程序代码,需使用()标记。A.<code></
HTML页面的标题代码应写在()标记内。A.<head></head> B.
要在HTML代码中加入注释,应使用()来标记。A.<!----> B./
随机试题
JosieMaranis(very)popular(among)youngpeople,whoregardher(as)(moresu
Duringatimeofprotractedeconomicduress,thewealthycanbecomepoor,______b
Yourblunttreatmentofdisputeswouldputotherpeopleinanegativeframeofw
Whatisthepercentageofyoungdrunkdriversamongalldrunkdrivers?[br][or
Hehadtoeata(n)______meal,orhewouldbetoolateforthefootballmatch.A、
PeoplewhospendalotoftimesurfingtheInternetaremorelikelytoshow
肠内营养的禁忌证包括( )。A.胃切除后发生倾倒综合征者 B.咽部手术后
行为人在法律上的认识错误有( )。 A.对因果关系认识错误 B.法律上认为
参加磷脂合成的核苷酸主要是( )。A.AMP B.GTP C.CTP D
(2020年真题)下列关于耕地占用税征收管理的表述中,符合税法规定的是( )。
最新回复
(
0
)