【计算机类职业资格】二级JAVA机试42及答案解析.doc

上传人:ideacase155 文档编号:1326653 上传时间:2019-10-17 格式:DOC 页数:3 大小:37KB
下载 相关 举报
【计算机类职业资格】二级JAVA机试42及答案解析.doc_第1页
第1页 / 共3页
【计算机类职业资格】二级JAVA机试42及答案解析.doc_第2页
第2页 / 共3页
【计算机类职业资格】二级JAVA机试42及答案解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、二级 JAVA 机试 42 及答案解析(总分:100.00,做题时间:90 分钟)一、B1基本操作题/B(总题数:1,分数:30.00)1.10 位同学参加某次团队测试,要求每位同学都必须及格、同时团队平均分不少于 80 分,整个团队才能够通过。每位同学的成绩可以通过随机数产生(0100)。请在程序的每条横线处填写一条语句,是程序的功能完整。 注意:请勿改动 main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 源程序文件代码清单如下: _; public class While public static void main(String args) int fenshu=60

2、 int sumfenshu=0; int i=1; while(fenshu=60) System. out. print in (fenshu+“ “); sumfenshu+=fenshu; i+; System.out.println(); if(_) System. out. println ( “团队通过“) else System. out.println (“团队测试不通过“); (分数:30.00)_二、B2简单应用题/B(总题数:1,分数:40.00)2.以下程序中,使用适当的布局管理器,在 Frame 框的“North”位置添加一句提示信息,在“South”位置添加一个

3、单行文本框,在这个文本框中输入的内容将会显示在“Center”位置。运行结果如下图所示。 (分数:40.00)_三、B3综合应用题/B(总题数:1,分数:30.00)3.下面是一个 Applet 程序,其功能是用一组坐标点绘制一个多边形,并通过沿坐标的垂直方向移动,把它移到窗口的下半部分,然后填充它。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。注意:不改动程序的结构,不得增行或删行。 源程序文件清单如下: import java.awt.*; import java.applet*; /* applet code=“ex11_3class“width=800 height=4

4、00 /applet */ public class ex11_3 extends Applet int x = 15,50,100,160,120,190 ; int y = 15,100,30, 15, 80, 50 ; public void init() setBackground (Color. lightGray); public void paint (Graphics g) int y2 = new int6; g. setColor (Color. red); Rectangle rect = getBounds(); Ug.drawPolygon (x, y2,6)/U;

5、for(int i=0; i6; i+) Uy2i = yi + (rect.height / 2)/U; Ug. fillPolygon (x, y, 6)/U; ex11_3. html HTML HEAD TITLEex11_3/TITLE /HEAD BODY applet code=“ex11_3.class“ width=800 height=400 /applet /BODY /HTML(分数:30.00)_二级 JAVA 机试 42 答案解析(总分:100.00,做题时间:90 分钟)一、B1基本操作题/B(总题数:1,分数:30.00)1.10 位同学参加某次团队测试,要求每

6、位同学都必须及格、同时团队平均分不少于 80 分,整个团队才能够通过。每位同学的成绩可以通过随机数产生(0100)。请在程序的每条横线处填写一条语句,是程序的功能完整。 注意:请勿改动 main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 源程序文件代码清单如下: _; public class While public static void main(String args) int fenshu=60; int sumfenshu=0; int i=1; while(fenshu=60) System. out. print in (fenshu+“ “); sumfens

7、hu+=fenshu; i+; System.out.println(); if(_) System. out. println ( “团队通过“) else System. out.println (“团队测试不通过“); (分数:30.00)_正确答案:()解析:import javamath.*; Mathrandom()*100 (i=10) int y = 15,100,30, 15, 80, 50 ; public void init() setBackground (Color. lightGray); public void paint (Graphics g) int y2

8、 new int6; g. setColor (Color. red); Rectangle rect = getBounds(); Ug.drawPolygon (x, y2,6)/U; for(int i=0; i6; i+) Uy2i = yi + (rect.height / 2)/U; Ug. fillPolygon (x, y, 6)/U; ex11_3. html HTML HEAD TITLEex11_3/TITLE /HEAD BODY applet code=“ex11_3.class“ width=800 height=400 /applet /BODY /HTML(分

9、数:30.00)_正确答案:()解析:g.drawPolygon(x,y,6) y2i+=yi+(rect.height/2) gfillPolygon(x,y2,6) 解析 本题主要考查 Applet 窗口编程和图形绘制的综合应用。解题关键是熟悉上述考点的基本要求,使用 Graphics 类的 drawPolygon()和 fillPolygon()方法绘制任意形状的图形,并且能结合数组进行编程实现。本题中第1 处,第 2 个参数应该是 y,而不是 y2。y2 还没有初始化;第 2 处,注意 y2 数组中的值是需要进行累加的,因此需要使用符号+=;第 3 处,fillPolygon()方法的第 2 个参数应该是 y2,绘制新的图形,并填充,若是 y 则不能绘制新的图形。

展开阅读全文
相关资源
猜你喜欢
  • EN 15600-2-2010 en Thermal insulation products for building equipment and industrial installations - In-situ thermal insulation formed from exfoliated vermiculite (EV) products - P.pdf EN 15600-2-2010 en Thermal insulation products for building equipment and industrial installations - In-situ thermal insulation formed from exfoliated vermiculite (EV) products - P.pdf
  • EN 15602-2008 en Security service providers - Terminology《安全服务公司 术语》.pdf EN 15602-2008 en Security service providers - Terminology《安全服务公司 术语》.pdf
  • EN 15603-2008 en Energy performance of buildings - Overall energy use and definition of energy ratings《建筑的能量性能 全部能量的使用和能量额定值的定义》.pdf EN 15603-2008 en Energy performance of buildings - Overall energy use and definition of energy ratings《建筑的能量性能 全部能量的使用和能量额定值的定义》.pdf
  • EN 15604-2009 en Fertilizers - Determination of different forms of nitrogen in the same sample containing nitrogen as nitric ammoniacal urea and cyanamide nitrogen《肥料 包含氮 氨 尿素和氰胺氮的.pdf EN 15604-2009 en Fertilizers - Determination of different forms of nitrogen in the same sample containing nitrogen as nitric ammoniacal urea and cyanamide nitrogen《肥料 包含氮 氨 尿素和氰胺氮的.pdf
  • EN 15605-2010 en Copper and copper alloys - Inductively coupled plasma optical emission spectrometry《铜和铜合金 感应耦合等离子体发射光谱法》.pdf EN 15605-2010 en Copper and copper alloys - Inductively coupled plasma optical emission spectrometry《铜和铜合金 感应耦合等离子体发射光谱法》.pdf
  • EN 15607-2009 en Foodstuffs - Determination of d-biotin by HPLC《粮食 HPLC法测定维生素D》.pdf EN 15607-2009 en Foodstuffs - Determination of d-biotin by HPLC《粮食 HPLC法测定维生素D》.pdf
  • EN 15608-2008 en Surface active agents - Quantitative determination of free fatty acid in alkylamidopropylbetaines - Gas-chromatographic method《表面活性剂 烷基酰氨丙基甜菜碱中游离脂肪酸的定量测定 气相色谱法》.pdf EN 15608-2008 en Surface active agents - Quantitative determination of free fatty acid in alkylamidopropylbetaines - Gas-chromatographic method《表面活性剂 烷基酰氨丙基甜菜碱中游离脂肪酸的定量测定 气相色谱法》.pdf
  • EN 15609-2012 en LPG equipment and accessories - LPG propulsion systems for boats yachts and other craft《液化石油气(LPG)和附件 船只 游艇和其他小船用液化石油气(LPG)推进系统 安装要求》.pdf EN 15609-2012 en LPG equipment and accessories - LPG propulsion systems for boats yachts and other craft《液化石油气(LPG)和附件 船只 游艇和其他小船用液化石油气(LPG)推进系统 安装要求》.pdf
  • EN 15610-2009 en Railway applications - Noise emission - Rail roughness measurement related to rolling noise generation《轨道交通 噪声排放 关于转动噪声产生的轨道粗糙度测量》.pdf EN 15610-2009 en Railway applications - Noise emission - Rail roughness measurement related to rolling noise generation《轨道交通 噪声排放 关于转动噪声产生的轨道粗糙度测量》.pdf
  • 相关搜索

    当前位置:首页 > 考试资料 > 职业资格

    copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
    备案/许可证编号:苏ICP备17064731号-1