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

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

1、二级 JAVA 机试 74 及答案解析(总分:100.00,做题时间:90 分钟)一、B1基本操作题/B(总题数:1,分数:30.00)1.下面程序的功能是输出字符串“HGPEDCBA”, 请在程序的每条横线处填写一个适当的语句,使程序的功能完整。 注意:请勿改动 main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 import java.io.*; public class InputString public static void main(String args ) String stringname= new _ (“ABCDEFGH“); for(int i= _

2、i=0;i-) System.out.println(String.valueOf(stringname._); (分数:30.00)_二、B2简单应用题/B(总题数:1,分数:40.00)2.请完成下列 Java 程序。程序的功能是对数组进行冒泡排序。冒泡排序算法的基本思路是把当前数据序列中的各相邻数据两两比较,发现任何一对数据间不符合要求的升序或降序关系则立即调换他们的顺序,从而保证相邻数据间符合升序或降序的关系。本题是进行升序排列。例如数组 a=30,1,-9,70,25则排序后为-9 1 25 30 70。 (分数:40.00)_三、B3综合应用题/B(总题数:1,分数:30.00)3

3、.下面的 Applet 程序通过内部类处理鼠标单击事件。在小程序中,如果点击鼠标,则在状态栏输出鼠标点击的坐标;如果双击鼠标,则显示一副图片,鼠标单击处为显示图片的左上角坐标,显示图片的宽度为200 像素,高度为 180 像素。请改正程序中的错误(有下划线的语句),使程序执行后,能得到预期的结果。注意:不改动程序的结构,不得增行或删行。 程序的执行结果为: (分数:30.00)_二级 JAVA 机试 74 答案解析(总分:100.00,做题时间:90 分钟)一、B1基本操作题/B(总题数:1,分数:30.00)1.下面程序的功能是输出字符串“HGPEDCBA”, 请在程序的每条横线处填写一个适

4、当的语句,使程序的功能完整。 注意:请勿改动 main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 import java.io.*; public class InputString public static void main(String args ) String stringname= new _ (“ABCDEFGH“); for(int i= _ i=0;i-) System.out.println(String.valueOf(stringname._); (分数:30.00)_正确答案:()解析:String stringnamelength()-1; cha

5、rAt(i) 解析 本题主要考查 for 循环语句和字符串String 类的基本操作。解答本题的关键是熟练掌握 for 循环语句和字符串 String 类的基本操作的知识。在 Java 语言中,字符串是作为对象出现的,由 javalangString 和 javalangStringBuffer 定义,分别用来处理长度不变和长度可变字符串,这两个类都被定义为 final,即参考数据类型。String 类中length()用于计算字符串的长度, charAt()方法用于获得字符串某一位置的字符。二、B2简单应用题/B(总题数:1,分数:40.00)2.请完成下列 Java 程序。程序的功能是对数

6、组进行冒泡排序。冒泡排序算法的基本思路是把当前数据序列中的各相邻数据两两比较,发现任何一对数据间不符合要求的升序或降序关系则立即调换他们的顺序,从而保证相邻数据间符合升序或降序的关系。本题是进行升序排列。例如数组 a=30,1,-9,70,25则排序后为-9 1 25 30 70。 (分数:40.00)_正确答案:()解析:jn-i; aj=aj+1; 解析 本题主要考查 for 循环语句的用法及数组的基本知识。解答本题的关键是能够熟练的掌握冒泡排序算法的思想及 for 循环语句的用法。排序是数据处理中经常使用的一种重要运算。常见排序分为:插入排序,选择排序,冒泡排序,基数排序等等。在本题中,

7、for(j=0;jn-i;j+)循环的功能是对上次排序的结果再进行排序从中选择处最小的数。aj=aj+1;语句的功能是把最小的数放在数组的最前面。三、B3综合应用题/B(总题数:1,分数:30.00)3.下面的 Applet 程序通过内部类处理鼠标单击事件。在小程序中,如果点击鼠标,则在状态栏输出鼠标点击的坐标;如果双击鼠标,则显示一副图片,鼠标单击处为显示图片的左上角坐标,显示图片的宽度为200 像素,高度为 180 像素。请改正程序中的错误(有下划线的语句),使程序执行后,能得到预期的结果。注意:不改动程序的结构,不得增行或删行。 程序的执行结果为: (分数:30.00)_正确答案:()解

8、析:drawImage(pic,xPos,yPos,200,180,this); pic=getImage(getDocumentBase(),“huajpg“); repaint(); 解析 本题主要考查 Applet 小程序的应用。解答本题的关键是能够熟练掌握 Applet 小程序的基本理论及其执行过程。在本题中,通过内部类 ClickMouse 处理鼠标单击事件。gdrawImage(pic,xPos,yPos,200,180,this);语句的功能是在指定的 Applet 显示区内画出图片,pic=getImage(getDocumentBase(),“hua.jpg“);语句功能是获取图片的 URL,repaint();语句功能是重新显示图片。

展开阅读全文
相关资源
猜你喜欢
  • DIN 18309-2016 German construction contract procedures (VOB) - Part C General technical specifications in construction contracts (ATV) - Ground treatment by grouting《德国建筑包工合同程序(VOB.pdf DIN 18309-2016 German construction contract procedures (VOB) - Part C General technical specifications in construction contracts (ATV) - Ground treatment by grouting《德国建筑包工合同程序(VOB.pdf
  • DIN 1831-1-1982 Side and face milling cutters with inserted cutting blades dimensions《镶嵌刀片的三面刃铣刀 第1部分 尺寸》.pdf DIN 1831-1-1982 Side and face milling cutters with inserted cutting blades dimensions《镶嵌刀片的三面刃铣刀 第1部分 尺寸》.pdf
  • DIN 1831-2-1990 Inserted tooth side and face milling cutters technical delivery consitions《镶齿的三面刃铣刀 交货技术条件》.pdf DIN 1831-2-1990 Inserted tooth side and face milling cutters technical delivery consitions《镶齿的三面刃铣刀 交货技术条件》.pdf
  • DIN 18311-2016 German construction contract procedures (VOB) - Part C General technical specifications in construction contracts (ATV) - Dredging work《德国建筑包工合同程序 (VOB) 第C部分 建筑包工合同 .pdf DIN 18311-2016 German construction contract procedures (VOB) - Part C General technical specifications in construction contracts (ATV) - Dredging work《德国建筑包工合同程序 (VOB) 第C部分 建筑包工合同 .pdf
  • DIN 18312-2016 German construction contract procedures (VOB) - Part C General technical specifications in construction contracts (ATV) - Underground construction work《德国建筑包工合同程序(VO.pdf DIN 18312-2016 German construction contract procedures (VOB) - Part C General technical specifications in construction contracts (ATV) - Underground construction work《德国建筑包工合同程序(VO.pdf
  • DIN 18313-2016 German construction contract procedures (VOB) - Part C General technical specifications in construction contracts (ATV) - Diaphragm walling《德国建筑合同程序(VOB) 第C部分 建筑合同通用.pdf DIN 18313-2016 German construction contract procedures (VOB) - Part C General technical specifications in construction contracts (ATV) - Diaphragm walling《德国建筑合同程序(VOB) 第C部分 建筑合同通用.pdf
  • DIN 18314-2016 German construction contract procedures (VOB) - Part C General technical specifications in construction contracts (ATV) - Sprayed concrete works《德国建筑包工合同程序 (VOB) 第C部.pdf DIN 18314-2016 German construction contract procedures (VOB) - Part C General technical specifications in construction contracts (ATV) - Sprayed concrete works《德国建筑包工合同程序 (VOB) 第C部.pdf
  • DIN 18315-2016 German construction contract procedures (VOB) - Part C General technical specifications in construction contracts (ATV) - Road construction - Surfacings without bind.pdf DIN 18315-2016 German construction contract procedures (VOB) - Part C General technical specifications in construction contracts (ATV) - Road construction - Surfacings without bind.pdf
  • DIN 18316-2016 German construction contract procedures (VOB) - Part C General technical specifications in construction contracts (ATV) - Road construction - Surfacings with hydraul.pdf DIN 18316-2016 German construction contract procedures (VOB) - Part C General technical specifications in construction contracts (ATV) - Road construction - Surfacings with hydraul.pdf
  • 相关搜索
    资源标签

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

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