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

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

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

2、u=0; int i=1; while(fenshu=60) System.out.println(fenshu+ “ ) sumfenshu+=fenshu; i+; System.out.println(); if(_) System.out.println(“团队通过“); else System. out. println ( “团队测试不通过“); (分数:30.00)_二、B2简单应用题/B(总题数:1,分数:40.00)2.请完成下列 Java 程序:假设某家银行,它可接受顾客的汇款,每做一次汇款,便可计算出汇款的总额。现有两个顾客,每人都分 3 次,每次 50 元将钱汇入。编写

3、一个程序,模拟实际作业。要求实现 2 个类,一个是银行类,一个是顾客类。 注意:请勿改动 main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。 程序运行结果如下: Customer2 :sum= 50 Customer1 :sum= 50 Customer1 :sum= 100 Customer2 :sum= 100 Customer1 :sum= 150 Customer2 :sum= 150 class bank private static int sum=0; public static void add(int.n,char c) int tmp=sum; _; try

4、 Thread.sleep(int) (2000-500+1)*(Math.random()+500); catch(InterruptedException e) sum=tmp; System.out.println(“Customer“+c+“ :sum= “+sum); class customer extends Thread static char flag17_2 = 1; public void run() char myflag17_2; synchronized(this) myflag17_2 = flag17_2+; for(int i=1;i=3;i+) _; pub

5、lic class ex17_2 public static void main(String args) customer c1=new customer(); customer c2=new customer(); c1.start(); c2.start(); (分数:40.00)_三、B3综合应用题/B(总题数:1,分数:30.00)3.下面是一个 Applet 程序,其功能是进行整数加法运算,要求有 3 个文本区域,2 个作为输入,一个作为输出,并且有异常处理来判断输入的数字是否符为整型,如果是则进行运算,否则抛出异常并显示于第3 个文本区域中。请改正程序中的错误(有下划线的语句),

6、使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 程序运行结果如下: (分数:30.00)_二级 JAVA 机试 34 答案解析(总分:100.00,做题时间:90 分钟)一、B1基本操作题/B(总题数:1,分数:30.00)1.10 位同学参加某次团队测试,要求每位同学都必须及格、同时团队平均分不少于 80 分,整个团队才能够通过。每位同学的成绩可以通过随机数产生(0100)。请在程序的每条横线处填写一条语句,是程序的功能完整。 注意:请勿改动 main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 _ pulic class While public stat

7、ic void main(String args ) int fenshu=60; int sumfenshu=0; int i=1; while(fenshu=60) System.out.println(fenshu+ “ ) sumfenshu+=fenshu; i+; System.out.println(); if(_) System.out.println(“团队通过“); else System. out. println ( “团队测试不通过“); (分数:30.00)_正确答案:()解析:import javamath*; Mathrandom()*100 (i=10) pu

8、blic static void add(int.n,char c) int tmp=sum; _; try Thread.sleep(int) (2000-500+1)*(Math.random()+500); catch(InterruptedException e) sum=tmp; System.out.println(“Customer“+c+“ :sum= “+sum); class customer extends Thread static char flag17_2 = 1; public void run() char myflag17_2; synchronized(th

9、is) myflag17_2 = flag17_2+; for(int i=1;i=3;i+) _; public class ex17_2 public static void main(String args) customer c1=new customer(); customer c2=new customer(); c1.start(); c2.start(); (分数:40.00)_正确答案:()解析:tmp=tmp+n bank.add(50,myflag17_2) 解析 本题主要考查线程的同步和设计简单的类来模拟现实问题的简单应用。解题关键是熟练掌握面向对象的编程思想,熟悉 J

10、ava 线程的同步编程,会使用 Math类的随机数方法。本题中,第 1 个空,银行类对客户的存款进行累加;第 2 个空,在客户类中,通过使用银行类的对象 bank 调用 add()方法实现 3 次汇款的操作,将钱数和客户标志作为参数传递给 add()方法。三、B3综合应用题/B(总题数:1,分数:30.00)3.下面是一个 Applet 程序,其功能是进行整数加法运算,要求有 3 个文本区域,2 个作为输入,一个作为输出,并且有异常处理来判断输入的数字是否符为整型,如果是则进行运算,否则抛出异常并显示于第3 个文本区域中。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 程序运行结果如下: (分数:30.00)_正确答案:()解析:add(tf1) add(11) tf3setText(IntegertoString(x) 解析 本题主要考查 Applet 的编程方法和执行过程,Applet 的生命周期和 AWT 的事件处理模型。解题关键是熟悉上述 3 个知识点并且能够灵活运用 Applet 和 AWT 的基本接口和基本构件。本题中,第一处和第二处应该交换位置,否则 Label 和TextField 的位置次序错误;第三处应该是第三个 TextField 的对象 tf3 调用 setText()方法,而不是tf2。

展开阅读全文
相关资源
猜你喜欢
  • BS PD ISO TS 17975-2015 Health informatics Principles and data requirements for consent in the Collection Use or Disclosure of personal health information《健康信息学 批准收集 使用或者披露个人健康信息的原则和数据要求》.pdf BS PD ISO TS 17975-2015 Health informatics Principles and data requirements for consent in the Collection Use or Disclosure of personal health information《健康信息学 批准收集 使用或者披露个人健康信息的原则和数据要求》.pdf
  • BS PD ISO TS 17988-2014 Dentistry Corrosion test methods for dental amalgam《牙科 牙科银汞合金的腐蚀试验方法》.pdf BS PD ISO TS 17988-2014 Dentistry Corrosion test methods for dental amalgam《牙科 牙科银汞合金的腐蚀试验方法》.pdf
  • BS PD ISO TS 18090-1-2015 Radiological protection Characteristics of reference pulsed radiation Photon radiation《辐射防护 基准脉冲辐射特性 光子辐射》.pdf BS PD ISO TS 18090-1-2015 Radiological protection Characteristics of reference pulsed radiation Photon radiation《辐射防护 基准脉冲辐射特性 光子辐射》.pdf
  • BS PD ISO TS 18130-2016 Dentistry Screw loosening test using cyclic torsional loading for implant body implant abutment connection of endosseous dental implants《牙科学 对骨内牙种植体的种植体 种植体基台连接进行采用循环扭转.pdf BS PD ISO TS 18130-2016 Dentistry Screw loosening test using cyclic torsional loading for implant body implant abutment connection of endosseous dental implants《牙科学 对骨内牙种植体的种植体 种植体基台连接进行采用循环扭转.pdf
  • BS PD ISO TS 18166-2016 Numerical welding simulation Execution and documentation《焊接数值模拟 执行和记录》.pdf BS PD ISO TS 18166-2016 Numerical welding simulation Execution and documentation《焊接数值模拟 执行和记录》.pdf
  • BS PD ISO TS 18220-2016 Water quality Larval development test with the harpacticoid copepod Nitocra spinipes《水质 猛水蚤幼体桡足动物发育试验》.pdf BS PD ISO TS 18220-2016 Water quality Larval development test with the harpacticoid copepod Nitocra spinipes《水质 猛水蚤幼体桡足动物发育试验》.pdf
  • BS PD ISO TS 18339-2015 Endotherapy devices Eyepiece cap and light guide connector《内疗器械 目镜盖和导光连接器》.pdf BS PD ISO TS 18339-2015 Endotherapy devices Eyepiece cap and light guide connector《内疗器械 目镜盖和导光连接器》.pdf
  • BS PD ISO TS 18340-2015 Endoscopes Trocar pins trocar sleeves and endotherapy devices for use with trocar sleeves《内窥镜 与套管针套一起使用的套管针针头 套管针套和内疗器械》.pdf BS PD ISO TS 18340-2015 Endoscopes Trocar pins trocar sleeves and endotherapy devices for use with trocar sleeves《内窥镜 与套管针套一起使用的套管针针头 套管针套和内疗器械》.pdf
  • BS PD ISO TS 18506-2014 Procedure to construct injury risk curves for the evaluation of road user protection in crash tests《用于评估碰撞试验中道路使用者保护性的伤害风险曲线构建程序》.pdf BS PD ISO TS 18506-2014 Procedure to construct injury risk curves for the evaluation of road user protection in crash tests《用于评估碰撞试验中道路使用者保护性的伤害风险曲线构建程序》.pdf
  • 相关搜索

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

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