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

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

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

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

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

4、tends Appletint 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();g.drawPolygon (x, y2,6);for(int i=0; i6; i+)y2i = yi + (rect.height / 2);

5、g. fillPolygon (x, y, 6);ex11_3. htmlHTMLHEADTITLEex11_3/TITLE/HEADBODYapplet code=“ex11_3.class“ width=800 height=400 /applet/BODY/HTML(分数:30.00)_二级 JAVA 机试-34 答案解析(总分:100.00,做题时间:90 分钟)一、1基本操作题(总题数:1,分数:30.00)1.10 位同学参加某次团队测试,要求每位同学都必须及格、同时团队平均分不少于 80 分,整个团队才能够通过。每位同学的成绩可以通过随机数产生(0100)。请在程序的每条横线处填

6、写一条语句,是程序的功能完整。注意:请勿改动 main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。源程序文件代码清单如下:_;public class Whilepublic static void main(String args)int fenshu=60;int sumfenshu=0;int i=1;while(fenshu=60)System. out. print in (fenshu+“ “);sumfenshu+=fenshu;i+;System.out.println();if(_)System. out. println ( “团队通过“)elseSystem

7、 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 = new int6;g. setColor (Color. red);Rectangle rect = getBounds();g.drawPolygon (x, y2,6);for(int i

8、0; i6; i+)y2i = yi + (rect.height / 2);g. fillPolygon (x, y, 6);ex11_3. htmlHTMLHEADTITLEex11_3/TITLE/HEADBODYapplet code=“ex11_3.class“ width=800 height=400 /applet/BODY/HTML(分数: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 则不能绘制新的图形。

展开阅读全文
相关资源
猜你喜欢
  • CIE X015-1998 Proceedings of the First CIE Cymposium on Lighting Quality 9 - 10 May 1998 at the National Research Council Canada Ottowa Ontario Canada《第一届CIE“照明质量”讨论会的会议记录 1998年5月9.pdf CIE X015-1998 Proceedings of the First CIE Cymposium on Lighting Quality 9 - 10 May 1998 at the National Research Council Canada Ottowa Ontario Canada《第一届CIE“照明质量”讨论会的会议记录 1998年5月9.pdf
  • CIE X016-1998 Reference Book Based on Presentation Given by Health and Safety Experts on Optical Radiation Hazards September 1-3 1998 Gaithersburg Maryland USA (Table of Contents O.pdf CIE X016-1998 Reference Book Based on Presentation Given by Health and Safety Experts on Optical Radiation Hazards September 1-3 1998 Gaithersburg Maryland USA (Table of Contents O.pdf
  • CIE X017-2000 Special Volume 24th Session of the CIE Warsaw June 24 - 30 1999 Late Papers (Table of Content Only) (E)《专用卷宗 第24届CIE会议 华沙 1999年6月24-30日 新闻局(仅目录)(E)》.pdf CIE X017-2000 Special Volume 24th Session of the CIE Warsaw June 24 - 30 1999 Late Papers (Table of Content Only) (E)《专用卷宗 第24届CIE会议 华沙 1999年6月24-30日 新闻局(仅目录)(E)》.pdf
  • CIE X018-1999 Proceedings of the CIE Symposium -99 75 Years of CIE Photometry 30 September - 02 October 1999 at the Hungarian Academy of Sciences Budapest Hungary (Table of Content.pdf CIE X018-1999 Proceedings of the CIE Symposium -99 75 Years of CIE Photometry 30 September - 02 October 1999 at the Hungarian Academy of Sciences Budapest Hungary (Table of Content.pdf
  • CIE X019-2001 Proceedings of Three CIE Workshops on Criteria for Road Lighting《三次CIE研讨会“1997年南非德班的道路照明标准”的会议记录 英国巴斯 1998 波兰华沙 1999》.pdf CIE X019-2001 Proceedings of Three CIE Workshops on Criteria for Road Lighting《三次CIE研讨会“1997年南非德班的道路照明标准”的会议记录 英国巴斯 1998 波兰华沙 1999》.pdf
  • CIE X020-2001 Proceedings of the CIE Expert Symposium 2001 on Uncertainty Evaluation Methods for Analysis of Uncertainties in Optical Radiation Measurement (23 - 24 January 2001 at.pdf CIE X020-2001 Proceedings of the CIE Expert Symposium 2001 on Uncertainty Evaluation Methods for Analysis of Uncertainties in Optical Radiation Measurement (23 - 24 January 2001 at.pdf
  • CIE X021-2001 PROCEEDINGS of the CIE Expert Symposium 2000 on Extended Range Colour Spaces《2000年CIE专家讨论会“扩展范围色域”的会议记录 》.pdf CIE X021-2001 PROCEEDINGS of the CIE Expert Symposium 2000 on Extended Range Colour Spaces《2000年CIE专家讨论会“扩展范围色域”的会议记录 》.pdf
  • CIE X022-2001 PROCEEDINGS of the 2nd CIE Expert Symposium on LED Measurement Standard methods for specifying and measuring LED and LED cluster characteristics《第2届CIE专家讨论会“规范和测量LED和.pdf CIE X022-2001 PROCEEDINGS of the 2nd CIE Expert Symposium on LED Measurement Standard methods for specifying and measuring LED and LED cluster characteristics《第2届CIE专家讨论会“规范和测量LED和.pdf
  • CIE X023-2002 Proceedings of two CIE Worshops on Photometric Measurement Systems for Road Lighting Installations《道路照明用光度测量系统CIE讨论会的会议记录2》.pdf CIE X023-2002 Proceedings of two CIE Worshops on Photometric Measurement Systems for Road Lighting Installations《道路照明用光度测量系统CIE讨论会的会议记录2》.pdf
  • 相关搜索

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

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