【计算机类职业资格】国家二级(JAVA)机试-试卷14及答案解析.doc

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

1、国家二级(JAVA)机试-试卷 14 及答案解析(总分:12.00,做题时间:90 分钟)一、基本操作题(总题数:2,分数:4.00)1.基本操作题()(分数:2.00)_2.请完善程序(程序文件名:Java_1.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。 题目要求 完成程序并运行,得到的结果如下图所示。(分数:2.00)_二、简单应用题(总题数:2,分数:4.00)3.简单应用题()(分数:2.00)_4.请完善程序(程序文件名:Java_2.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语

2、句内容。 题目要求 程序显示一个窗口。该窗口包含一个按钮和一个文本域,当单击按钮时将在文本域中显示当前日期,如下图所示。 (分数:2.00)_三、综合应用题(总题数:2,分数:4.00)5.综合应用题()(分数:2.00)_6.请完善程序(程序文件名:Java_3.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。 题目要求 统计一个英文文本字符串包含的英文元音字母的个数,使程序的运行结果如下: The text contained vowels:88 源程序: public class Java_3 public static void ma

3、in(String args) String text = “ Beijing, the Capital City, is the political, “ + “cultural and diplomatic centre of China. It has“ + “become a modern international cosmopolitan city“ + “ with more than 11 million people. The Capital“ + “ International Airport, 23.5 km from the city centre,“ + “is Ch

4、inas largest and most advanced airport. “ ; int vowels =0; int (1) = text.length(); for(int i = 0;itextLength; i+) char ch=Character.toLowerCase( text. (2) ); if(ch=a|ch=e|ch=i|ch=o|ch=u) (3) ; System.out.println( “The text contained vowels:“ + vowels +“/n“); (分数:2.00)_国家二级(JAVA)机试-试卷 14 答案解析(总分:12.

5、00,做题时间:90 分钟)一、基本操作题(总题数:2,分数:4.00)1.基本操作题()(分数:2.00)_解析:2.请完善程序(程序文件名:Java_1.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。 题目要求 完成程序并运行,得到的结果如下图所示。(分数:2.00)_正确答案:(正确答案:(1)“Hello“ (2)Java_1()解析:解析:根据题目输出结果可以看出,实例化后未给重新赋值时,变量 s 的内容是字符串“Hello“,所以对变量 S 的初始化值即“Hello“。程序中定义 d 为 Java_1 类的对象,所以对类实例化,

6、即通过默认的构造方法创建对象。 程序解析 本程序通过类实例化获取类对象,改变对象的变量,将其通过对话框输出。二、简单应用题(总题数:2,分数:4.00)3.简单应用题()(分数:2.00)_解析:4.请完善程序(程序文件名:Java_2.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。 题目要求 程序显示一个窗口。该窗口包含一个按钮和一个文本域,当单击按钮时将在文本域中显示当前日期,如下图所示。 (分数:2.00)_正确答案:(正确答案:Java_2 f.addWindowListener)解析:解析:程序的注释中已经给出注册窗口监听器,而且

7、由下面的方法 windowClosing 可以看出是窗口监听器,所以是给 Frame 类实例 f 注册窗口监听器。 程序解析 本程序通过按钮在文本域显示当前系统时间。程序中用到了构造方法,因为在 main()方法中只是创建了对象,进行了实例化。另外也涉及事件监听接口。三、综合应用题(总题数:2,分数:4.00)5.综合应用题()(分数:2.00)_解析:6.请完善程序(程序文件名:Java_3.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。 题目要求 统计一个英文文本字符串包含的英文元音字母的个数,使程序的运行结果如下: The text

8、contained vowels:88 源程序: public class Java_3 public static void main(String args) String text = “ Beijing, the Capital City, is the political, “ + “cultural and diplomatic centre of China. It has“ + “become a modern international cosmopolitan city“ + “ with more than 11 million people. The Capital“

9、 “ International Airport, 23.5 km from the city centre,“ + “is Chinas largest and most advanced airport. “ ; int vowels =0; int (1) = text.length(); for(int i = 0;itextLength; i+) char ch=Character.toLowerCase( text. (2) ); if(ch=a|ch=e|ch=i|ch=o|ch=u) (3) ; System.out.println( “The text contained vowels:“ + vowels +“/n“); (分数:2.00)_正确答案:(正确答案:textLength charAt(i) vowels+)解析:解析:由最后的输出语句判断出变量 vowels 表述元音的个数,因此统计出一个元音变量 vowels 就加 1,所以此处应填 vowels+。 程序解析 本程序统计一个字符串中元音字母的个数,然后输出。由于统计时是不区分大小写的,所以在比较前,先将字符串的每个字母都小写,再进行比较。

展开阅读全文
相关资源
猜你喜欢
  • BS EN ISO 16911-2-2013 Stationary source emissions Manual and automatic determination of velocity and volume flow rate in ducts Automated measuring systems《固定污染源排放 通风管速率和流量的手工和自动测定.pdf BS EN ISO 16911-2-2013 Stationary source emissions Manual and automatic determination of velocity and volume flow rate in ducts Automated measuring systems《固定污染源排放 通风管速率和流量的手工和自动测定.pdf
  • BS EN ISO 16925-2014 Paints and varnishes Determination of the resistance of coatings to pressure water-jetting《涂料和清漆 涂层耐压力水喷射的测定》.pdf BS EN ISO 16925-2014 Paints and varnishes Determination of the resistance of coatings to pressure water-jetting《涂料和清漆 涂层耐压力水喷射的测定》.pdf
  • BS EN ISO 16927-2014 Paints and varnishes Determination of the overcoatability and recoatability of a coating《涂料和清漆 涂层的再涂性和重涂性的测定》.pdf BS EN ISO 16927-2014 Paints and varnishes Determination of the overcoatability and recoatability of a coating《涂料和清漆 涂层的再涂性和重涂性的测定》.pdf
  • BS EN ISO 16931-2009 Animal and vegetable fats and oils - Determination of polymerized triacylglycerols by high-performance size- exclusion chromatography (HPSEC)《动植物油脂 高效体积排阻色谱法(H.pdf BS EN ISO 16931-2009 Animal and vegetable fats and oils - Determination of polymerized triacylglycerols by high-performance size- exclusion chromatography (HPSEC)《动植物油脂 高效体积排阻色谱法(H.pdf
  • BS EN ISO 16946-2017 Non-destructive testing Ultrasonic testing Specification for step wedge calibration block《无损试验 超声波检测 阶跃式光楔校准块的规格》.pdf BS EN ISO 16946-2017 Non-destructive testing Ultrasonic testing Specification for step wedge calibration block《无损试验 超声波检测 阶跃式光楔校准块的规格》.pdf
  • BS EN ISO 16948-2015 Solid biofuels Determination of total content of carbon hydrogen and nitrogen《固体生物燃料 碳 氢和氮总含量的测定》.pdf BS EN ISO 16948-2015 Solid biofuels Determination of total content of carbon hydrogen and nitrogen《固体生物燃料 碳 氢和氮总含量的测定》.pdf
  • BS EN ISO 16954-2015 Dentistry Test methods for dental unit waterline biofilm treatment《牙科 牙科水线生物膜处理的试验方法》.pdf BS EN ISO 16954-2015 Dentistry Test methods for dental unit waterline biofilm treatment《牙科 牙科水线生物膜处理的试验方法》.pdf
  • BS EN ISO 16960-2014 Natural gas Determination of sulfur compounds Determination of total sulfur by oxidative microcoulometry method《天然气 硫化物的测定 使用氧化微库仑法测定总含硫量》.pdf BS EN ISO 16960-2014 Natural gas Determination of sulfur compounds Determination of total sulfur by oxidative microcoulometry method《天然气 硫化物的测定 使用氧化微库仑法测定总含硫量》.pdf
  • BS EN ISO 16961-2015 Petroleum petrochemical and natural gas industries Internal coating and lining of steel storage tanks《石油 石化和天然气工业 钢储罐内涂层与内衬》.pdf BS EN ISO 16961-2015 Petroleum petrochemical and natural gas industries Internal coating and lining of steel storage tanks《石油 石化和天然气工业 钢储罐内涂层与内衬》.pdf
  • 相关搜索

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

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