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

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

1、二级 JAVA机试 13及答案解析(总分:100.00,做题时间:90 分钟)一、B1基本操作题/B(总题数:1,分数:30.00)1.请在每条横线处填写一个语句,使程序的功能完整,且输出结果为 911。 注意:请勿改动 main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 public class Outer public static void main(String args) Outer i = new Outer(); i.taskInner(); public class Inner private int size; public void doSomething(

2、int size) _访问局部变量 thissize+;访问内部类的成员变量 _访问外部类的成员变量 Systemoutprintln(size+“ “+thissize+“ “+Outerthissize); public void taskInner() _ kdoSomething(8); private static int size; (分数:30.00)_二、B2简单应用题/B(总题数:1,分数:40.00)2.请完成下列 Java程序:输入 2个整数,求最大公约数。要求有 2个单行文本区作为输入,2 个按钮,一个点击完成计算,一个点击退出程序。 注意:请勿改动 main()主方法

3、和其他已有语句内容,仅在下划线处填入适当的语句。 程序运行结果如下: (分数:40.00)_三、B3综合应用题/B(总题数:1,分数:30.00)3.下面是一个 Applet程序,其功能是输入 3个双精度浮点数:a,b,c,构成一个一元二次方程,a*x*x+b*x+c=0,其判别式 d=b*b-4*a*c,若 d为负数则输出“没有实根”,否则打印出 2个实根。要求,有 3个输入框,输入 a,b,c,一个按钮,点击实现求根过程,一个不可编辑的文本区,用作输出结果。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 程序运行结果如下: (分数:

4、30.00)_二级 JAVA机试 13答案解析(总分:100.00,做题时间:90 分钟)一、B1基本操作题/B(总题数:1,分数:30.00)1.请在每条横线处填写一个语句,使程序的功能完整,且输出结果为 911。 注意:请勿改动 main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 public class Outer public static void main(String args) Outer i = new Outer(); i.taskInner(); public class Inner private int size; public void doSome

5、thing(int size) _访问局部变量 thissize+;访问内部类的成员变量 _访问外部类的成员变量 Systemoutprintln(size+“ “+thissize+“ “+Outerthissize); public void taskInner() _ kdoSomething(8); private static int size; (分数:30.00)_正确答案:()解析:size+; Outerthissize+; Inner k=new Inner(); 解析 本题主要考查内部类的概念,super,this关键字的用法。解答本题的关键是熟练掌握 super,thi

6、s关键字的用法。在本题中 size+;语句是访问局部变量 size,Outer.this.size+;语句的功能是访问外部类的成员变量 size,Inner K=new Inner();语句的功能是生成内部类 Inner的对象 K。二、B2简单应用题/B(总题数:1,分数:40.00)2.请完成下列 Java程序:输入 2个整数,求最大公约数。要求有 2个单行文本区作为输入,2 个按钮,一个点击完成计算,一个点击退出程序。 注意:请勿改动 main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。 程序运行结果如下: (分数:40.00)_正确答案:()解析:r=a%b a=b 解析

7、本题主要考查 AWT基本构件和事件处理机制以及基本的求最大公因数的算法。解题关键是掌握 Button,Panel,Label 等构件的使用方法,会处理整数异常,熟练掌握 while语句用法。本题中,第 1个空,r 为 a除以 b的余数;第 2个空,a 更新为 b的值。三、B3综合应用题/B(总题数:1,分数:30.00)3.下面是一个 Applet程序,其功能是输入 3个双精度浮点数:a,b,c,构成一个一元二次方程,a*x*x+b*x+c=0,其判别式 d=b*b-4*a*c,若 d为负数则输出“没有实根”,否则打印出 2个实根。要求,有 3个输入框,输入 a,b,c,一个按钮,点击实现求根

8、过程,一个不可编辑的文本区,用作输出结果。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 程序运行结果如下: (分数:30.00)_正确答案:()解析:d=a2*a2-4.0*a1*a3 x2=(-a2-Mathsqrt(d)/(2.0*a1) obj21_3doReal(a,b,c,tf4) 解析 本题主要考查 Applet窗口编程和 AWT基本构件的使用和事件处理机制以及一元二次方程组的求根公式。解题关键是熟悉基本组件 Button,Panel,Label 等的用法和事件处理机制,熟悉一元二次方程组的求解,会使用 Math类中给出的常用方法进行简单的数学计算。本题中,第 1处,求判别式,注意判别式的公式是 d=b*b-4*a*c,弄清楚 doReal()方法中的参数对应的关系;第 2处,求根公式的表示,应该-a2-Math.sqrt(d),否则,两个根一样;第 3处,对象 obj21_3调用 doReal()方法时, 注意,最后 1个参数是 TextField类的对象,而不是 Label类的对象。

展开阅读全文
相关资源
猜你喜欢
  • BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf
  • BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf
  • BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf
  • BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf
  • BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf
  • BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf
  • BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf
  • BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf
  • BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf
  • 相关搜索

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

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