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

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

1、二级 JAVA机试 19及答案解析(总分:100.00,做题时间:90 分钟)一、B1基本操作题/B(总题数:1,分数:30.00)1.下面是关于字符界面基本输入输出的程序,请在程序的每条横线处填写一个语句,使程序的功能完整。 注意:请勿改动 main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 _ public class SimpleCharInOut public static void main(String args) char c=“ “; System.out.println(“Enter a character please: “); try _/接受用户键盘输入

2、的字符并保存在变量 c中 catch(_e) System.out.println(“Youve entered character “+c); (分数:30.00)_二、B2简单应用题/B(总题数:1,分数:40.00)2.请完成下列 Java程序:计算下列级数之和,直到该项之绝对值小于 0.001为止。 S=1/1!-12!+13!-14!+ 注意:请勿改动 main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。 程序运行结果如下: i=1 s=1.0 i=2 s=0.5 i=3 s=0.6666666666666666 1=4 s=0.625 i=5 s=0.63333333

3、33333333 1=6 s=0.6319444444444444 public class ex28_2 public static void main(String args) double s=0.0,sign=-1.0,t,f=1.0; for(int i=1;i+) f=f*i; _; t=sign/f; if(_) break; s=s+t; System.out.println(“i=“+i+“ s=“+s); (分数:40.00)_三、B3综合应用题/B(总题数:1,分数:30.00)3.下面是一个 Applet程序,其功能是实现对 JButton类的扩展,封装成上网助力一样的

4、按钮类,每个按钮对象对应一个 URL 地址,点击则访问相应的 URL。要求在窗口中从上到下排列 3个这样的按钮。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 程序运行结果如下: (分数:30.00)_二级 JAVA机试 19答案解析(总分:100.00,做题时间:90 分钟)一、B1基本操作题/B(总题数:1,分数:30.00)1.下面是关于字符界面基本输入输出的程序,请在程序的每条横线处填写一个语句,使程序的功能完整。 注意:请勿改动 main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 _ public class

5、SimpleCharInOut public static void main(String args) char c=“ “; System.out.println(“Enter a character please: “); try _/接受用户键盘输入的字符并保存在变量 c中 catch(_e) System.out.println(“Youve entered character “+c); (分数:30.00)_正确答案:()解析:import javaio*; c=(char)Systemin.read(); IOException 或 Exception 解析 本题主要考查 tr

6、y-catch异常捕获结构。解答本题的关键是熟练掌握异常的捕获知识。在本题中,import javaio*;语句的功能是导入 javaio 包,c=(char)Systeminread();语句的功能是从键盘缓冲区获得一个字符数据,并赋给字符变量 C,IOExcepfion e 声明一个 IOExcepfion型对象 e。二、B2简单应用题/B(总题数:1,分数:40.00)2.请完成下列 Java程序:计算下列级数之和,直到该项之绝对值小于 0.001为止。 S=1/1!-12!+13!-14!+ 注意:请勿改动 main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。 程序运行结

7、果如下: i=1 s=1.0 i=2 s=0.5 i=3 s=0.6666666666666666 1=4 s=0.625 i=5 s=0.6333333333333333 1=6 s=0.6319444444444444 public class ex28_2 public static void main(String args) double s=0.0,sign=-1.0,t,f=1.0; for(int i=1;i+) f=f*i; _; t=sign/f; if(_) break; s=s+t; System.out.println(“i=“+i+“ s=“+s); (分数:40.

8、00)_正确答案:()解析:sign=-sign Mathabs(t)0001 解析 本题主要考查 for循环和条件语句控制程序流程。解题关键是会根据公式写出相应的算法解决问题。本题中,第 1个空,由于公式里每一项的符号都是交替变化的,所以这里需要改变符号;第 2个空,判断是否中断循环的条件,需要用 Mathabs()方法来进行绝对值的比较。三、B3综合应用题/B(总题数:1,分数:30.00)3.下面是一个 Applet程序,其功能是实现对 JButton类的扩展,封装成上网助力一样的按钮类,每个按钮对象对应一个 URL 地址,点击则访问相应的 URL。要求在窗口中从上到下排列 3个这样的按

9、钮。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 程序运行结果如下: (分数:30.00)_正确答案:()解析:new GridLayout(3,1) (ButtonURL)aegetSource() showDocument(load) 解析 本题主要考查面向对象的基本程序设计思想和 Applet事件处理机制及 Applet和 Application相结合的程序设计。解题关键是熟悉 swing的基本构件,并会根据需要进行扩展,这里的 ButtonURL类就是对 JButton类的扩展,熟悉布局的基本操作等。本题中,第 1处,按题目要求,应该是纵向排列的 3个按钮;第 2处,ae 对象调用 getSource()方返回的是 JButton类的对象,这里需要 ButtonURL的对象,所以需要进行转换;第 3处,参数错误,应该是对象 btnClick的成员变量 strAddr的值。

展开阅读全文
相关资源
猜你喜欢
  • NF X10-107-1990 Assessment of uncertainty in the calibration and use of flow measurement devices Part 1  linear calibration relationships 《流量测量装置的校正和使用中的不确定度评定 第1部分 线性校正关系式》.pdf NF X10-107-1990 Assessment of uncertainty in the calibration and use of flow measurement devices Part 1 linear calibration relationships 《流量测量装置的校正和使用中的不确定度评定 第1部分 线性校正关系式》.pdf
  • NF X10-108-1988 Assessment of uncertainty in the calibration and use of flow measurement devices Part 2  non-linear calibration relationships 《流量测量装置校准和使用时误差的评估 第2部分 非线性校准关系》.pdf NF X10-108-1988 Assessment of uncertainty in the calibration and use of flow measurement devices Part 2 non-linear calibration relationships 《流量测量装置校准和使用时误差的评估 第2部分 非线性校准关系》.pdf
  • NF X10-112-1977 Measurement of fluid flow in closed conduites velocity area method using pitot static tubes 《密封管道中液体流量的测量 用皮托静压管的速度面积法》.pdf NF X10-112-1977 Measurement of fluid flow in closed conduites velocity area method using pitot static tubes 《密封管道中液体流量的测量 用皮托静压管的速度面积法》.pdf
  • NF X10-113-1982 Determination of flowrate of fluids in closed conduits of circular cross-section Method of velocity measurement at one point of the cross-section 《圆截面密封管道中液体流量的测定 剖.pdf NF X10-113-1982 Determination of flowrate of fluids in closed conduits of circular cross-section Method of velocity measurement at one point of the cross-section 《圆截面密封管道中液体流量的测定 剖.pdf
  • NF X10-120-1995 Measurement of conductive liquid flow in closed conduits Method using electromagnetic flow meters 《封闭管道中导电液体流量的测量 电磁流量计测量法》.pdf NF X10-120-1995 Measurement of conductive liquid flow in closed conduits Method using electromagnetic flow meters 《封闭管道中导电液体流量的测量 电磁流量计测量法》.pdf
  • NF X10-121-1993 Measurement of fluid flow in closed conduits Methods of evaluating the performance of electromagnetic flow-meters for liquids 《封闭管道中流体流量的测量 液体电磁流量计的性能评价方法》.pdf NF X10-121-1993 Measurement of fluid flow in closed conduits Methods of evaluating the performance of electromagnetic flow-meters for liquids 《封闭管道中流体流量的测量 液体电磁流量计的性能评价方法》.pdf
  • NF X10-131-1974 Measurement of water flow in closed conduits tracer methods part i general 《密封管道中水流量的测定 示踪法 第1部分:综合》.pdf NF X10-131-1974 Measurement of water flow in closed conduits tracer methods part i general 《密封管道中水流量的测定 示踪法 第1部分:综合》.pdf
  • NF X10-132-1975 Measurement of water flow in closed conduits Tracer methods part II  constant rate injection method using non-radioactive tracers 《密封管道中水流量的测定 示踪法 第2部分:使用非放射性示踪物的恒速.pdf NF X10-132-1975 Measurement of water flow in closed conduits Tracer methods part II constant rate injection method using non-radioactive tracers 《密封管道中水流量的测定 示踪法 第2部分:使用非放射性示踪物的恒速.pdf
  • NF X10-133-1977 Measurement of water flow rate in closed conduits Tracer methods Part III constant rate injection method using radioactive tracers 《密封管道中水流速的测定 示踪法 第3部分:放射性示踪器恒流速喷射.pdf NF X10-133-1977 Measurement of water flow rate in closed conduits Tracer methods Part III constant rate injection method using radioactive tracers 《密封管道中水流速的测定 示踪法 第3部分:放射性示踪器恒流速喷射.pdf
  • 相关搜索

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

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