首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读以下说明和JAVA 2代码,填入(n)处。 [说明] 以下JAVA程序设计了类CSet,使用同一个名称(set)的method来传入数据。仔细阅读[代码6-1)、[代码6-2]和[代码6-3]和相关注释,将程序补充完整。 [代码6-
阅读以下说明和JAVA 2代码,填入(n)处。 [说明] 以下JAVA程序设计了类CSet,使用同一个名称(set)的method来传入数据。仔细阅读[代码6-1)、[代码6-2]和[代码6-3]和相关注释,将程序补充完整。 [代码6-
admin
2009-02-15
21
问题
阅读以下说明和JAVA 2代码,填入(n)处。
[说明]
以下JAVA程序设计了类CSet,使用同一个名称(set)的method来传入数据。仔细阅读[代码6-1)、[代码6-2]和[代码6-3]和相关注释,将程序补充完整。
[代码6-1]
import java.io.*;
class CSet
{
private int width;
private int height;
(1)
public void set(String color)
{
col=color; //(a)可输入长方形的颜色
}
public void set (iht w, int h)
{
width=w; //(b)可输入长方形的宽和高
height=h;
}
public void set (String color, int w, int h)
{
col=color; //(c)可输入长方形的颜色、宽和高
width=w;
height=h;
}
public void show ( )
{
System.out.println ("n\长方形的颜色为: "+col);
System.out.println ("n\长方形宽为: "+width+" 长方形高为: "+height");
}
}
[代码6-2]
public class hw8_3
{
public static void main (String args[]) throws IOException
{
intw, h; //声明宽、长变量,并给予赋值
String color, k;
CSet rect1;
rect1=new CSet ( );
System.out.print ("\n请输入颜色:: ");
color=input ( );
System.out.print ("请输入宽度:: ");
k=input ( );
w=Integer.parseInt (k);
System.out.print ("请输入高度:: ");
k=input( );
h=Integer.parseInt (k);
(2)//设置长方形的颜色
(3)//设置长方形的宽、高
rectl.show ( );
(4)//设置长方形的颜色和宽、高
rectl.show ( );
}
[代码6-3]
public static String input( ) throws IOException//输入函数
{
String str;
BufferedReader buf;
(5)
str=buf.readLine ( )
return str;
}
}
选项
答案
(1)pfivate String col; (2)rectl.set(color); (3)rectl.set(w,h); (4)rectl.set(color,w,h); (5)buf=new BufferedReader(new InputStreamReader(System.in));
解析
程序中定义了类CSet,使用同一个名称(set)的method来传入数据。本题需要考生仔细阅读代码,因为代码中有的变量是在后来出现的,而前边又没有定义,那么肯定需要在空缺处定义。另外,有些语句逻辑上没有先后关系,但填空时需要按顺序填写,因为有注释区分。本题并不难,但代码长。设计此题的目的希望考生又较强的阅读代码能力,因为只有读完了全部代码,才可以明白前面的空缺应该填写什么。
转载请注明原文地址:https://kaotiyun.com/show/MgDZ777K
本试题收录于:
软件设计师下午应用技术考试题库软考中级分类
0
软件设计师下午应用技术考试
软考中级
相关试题推荐
在.I/O设备与主机问进行数据传输时,CPU只需在开始和结束时作少量处理,而无需干预数据传送过程的是()方式。
页式存储系统的逻辑地址是由页号和页内地址两部分组成。假定页面的大小为4K,地址变换过程如下图所示,图中逻辑地址用十进制表示。图中有效地址经过变换后,十进制物理地址a应为(18)。
在程序执行过程中,Cache与主存的地址映像由()。
GB/T18905-2002《软件工程产品评价》中确定的通用评价过程包括四个方面,即:确立评价需求,规定评价,设计评价和执行评价,其中有关“规定评价”部分包含的内容有(52)。
关于软件测试与软件开发的认识,不正确的是______。A.软件生命周期各个阶段都可能产生错误B.软件测试是独立于软件开发的一个工作C.软件开发的需求分析和设计阶段就应开始测试工作D.测试越早进行,越有助于提高被测软件的质量
下图是一个软件项目的活动图,其中顶点表示项目里程碑,连接顶点的边表示包含的活动,则完成该项目的最少时间为_____________(34)天。活动BD最多可以晚开始______________(35)天而不会影响整个项目的进度。(34)
设有关系模式R(A1,A2,A3,A4,A5,A6),其中:函数依赖集F={A1→A2,A1A3→A4,A5A6→A1,A2A5→A6,A3A5→A6),则___________(21)是关系模式R的一个主键,R规范化程度最高达到____________(
假设磁盘块与缓冲区大小相同,每个盘块读入缓冲区的时间为10μs,由缓冲区送至用户区的时间是5μs,系统对每个磁盘块数据的处理时间为2μs。若用户需要将大小为10个磁盘块的Docl文件逐块从磁盘读入缓冲区,并送至用户区进行处理,那么采用单缓冲区需要花费的时间
V模型是具有代表意义的测试模型,以下理解正确的是______。A.V模型认为测试阶段是与开发阶段并行的B.V模型是软件开发螺旋模型的变种,它反映了测试活动与分析和设计的关系C.V模型造成需求分析阶段隐藏的问题一直到后期的验收测试才被发现D.V模型是
阅读以下说明和流程图(如图3所示),回答问题1和问题2。【说明】本流程图实现从成绩文件生成学生成绩一览表。某中学某年级的学生成绩数据(分数)登录在成绩文件10中,其记录格式见表2: 由该成绩文件生成见表3的学生成绩一览表
随机试题
下列哪种激素的分泌不受腺垂体的控制
肝颈静脉回流征不出现于下列哪种疾病()
充抵保证金的有价证券,在计算保证金金额时应当以证券市值按一定折算率进行折算,其中折算率最高的是()。
公共物品的效率由()组成。
边防工作可以分为()。
马克思主义哲学认为,社会进步具有曲折性和___________。社会的进步是通过_____________实现的。因为____________对于旧势力和反动阶级来说,就意味着被推翻、被打倒、被抛出历史舞台。正因为如此,他们的抵御和反抗是顽固而持久的。这
下列有关数据库的描述,正确的是()。
Whatwastheresearchabout?
Thegameendedafewhoursearly,leavingplayersand______unsatisfied.
Duringsleep,thefatigue(疲劳)ofthebody【S1】______andrecuperation(恢复)begins.Thetiredmindgathersnewenergy.Onceawake,the
最新回复
(
0
)