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

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

1、二级 JAVA机试 30及答案解析(总分:100.00,做题时间:90 分钟)一、B1基本操作题/B(总题数:1,分数:30.00)1.下列程序中,分别计算 1,2,3,10 的阶乘,并输出计算结果,请将程序补充完整。 程序运行结果如下: 1!=1 2!=2 3!=6 4!=24 5!=120 6!=720 7!=5040 8!=40320 9!=362880 10!=3628800 public class ex10_1 public static void main(Stringargs) long 1 Factorial; for(int i=1;i=10;i+) _; for(int

2、j=2;_;j+) _; System.out.println(i+ “ ! =“ + 1Factorial); (分数:30.00)_二、B2简单应用题/B(总题数:1,分数:40.00)2.请完成下列 Java程序:输出某年的某月有多少天数,要求生成 2个输入对话框,一个输入年份,一个输入月份,并且能检查输入的数字是否符合要求,如果符合要求,则根据输入的年份和月份计算出这一年的这一月有多少天。提示:闰年为年数能被 4整除但是不能被 100整除。 注意:请勿改动 main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。 程序运行结果如下: (分数:40.00)_三、B3综合应用题/

3、B(总题数:1,分数:30.00)3.下面是一个 Applet程序,其功能是建立一个图形用户界面的窗口,包括一个文本显示区和一个按钮,点击按钮,可以在文本区已有的文本基础上追加显示 10条“Welcome to the NCR Examination!”信息,并且文本区由滚动条控制文本的上下滚动。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 程序运行结果如下: (分数:30.00)_二级 JAVA机试 30答案解析(总分:100.00,做题时间:90 分钟)一、B1基本操作题/B(总题数:1,分数:30.00)1.下列程序中,分别计算

4、 1,2,3,10 的阶乘,并输出计算结果,请将程序补充完整。 程序运行结果如下: 1!=1 2!=2 3!=6 4!=24 5!=120 6!=720 7!=5040 8!=40320 9!=362880 10!=3628800 public class ex10_1 public static void main(Stringargs) long 1 Factorial; for(int i=1;i=10;i+) _; for(int j=2;_;j+) _; System.out.println(i+ “ ! =“ + 1Factorial); (分数:30.00)_正确答案:()解析:

5、1Factorial=1 j=i 1Factorial*=j 解析 本题主要考查 for循环语句和简单的数学计算。解题要点是熟练掌握 for循环语句,会解决一些简单的数学问题,熟悉求阶乘的算法,并用程序实现这一算法。本题中,第 1个空,要对 1Factorial变量进行初始化,因为需要计算 1到 10一共 10个数的阶乘,所以最外层循环共执行 10次,每次都需要将 1Factorial重新初始化为 1:第 2个空,内层循环实现某个数的阶乘,因此循环变量的上界应该是 i=i;第 3个空,阶乘算法的公式,做累乘。二、B2简单应用题/B(总题数:1,分数:40.00)2.请完成下列 Java程序:输

6、出某年的某月有多少天数,要求生成 2个输入对话框,一个输入年份,一个输入月份,并且能检查输入的数字是否符合要求,如果符合要求,则根据输入的年份和月份计算出这一年的这一月有多少天。提示:闰年为年数能被 4整除但是不能被 100整除。 注意:请勿改动 main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。 程序运行结果如下: (分数:40.00)_正确答案:()解析:nMonth0 | nMonth12 (nYear%4 =0)&!(nYear%100 = 0) | (nYear%400 = 0) 解析 本题主要考查 swing图形用户界面设计和 case语句的简单应用。解题关键是会用

7、 swing的容器面板构造对话框,熟悉判断闰年的条件语句的设计,判断输入是否符合程序要求的条件语句设计,case 语句的设计。本题中,第 1个空,判断输入的月份值应该在 1到 12月之间,否则给出提示信息并退出;第 2个空,闰年的判断,将题干中的提示用代码实现。三、B3综合应用题/B(总题数:1,分数:30.00)3.下面是一个 Applet程序,其功能是建立一个图形用户界面的窗口,包括一个文本显示区和一个按钮,点击按钮,可以在文本区已有的文本基础上追加显示 10条“Welcome to the NCR Examination!”信息,并且文本区由滚动条控制文本的上下滚动。请改正程序中的错误(

8、有下划线的语句),使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 程序运行结果如下: (分数:30.00)_正确答案:()解析:jtp.setText(jtp.getText() + “ Welcome to the NCR Examination!/n“) cp.add(BorderLayout.SOUTH,jb) frm.getContentPane().add(obj10_3) 解析 本题主要考查 Applet和 swing结合进行图形用户界面设计的综合应用。解题关键是掌握 swing的基本构件 JTextPanel, JButton,JScrollPanel 的用法,掌握 BorderLayout布局管理器的使用方法,以及熟练掌握最基本的对象概念。本题中,第 1处, JTextPanel 的 2个基本的方法,setText()和 getText()的功能,熟悉这 2个功能,则很容易就能将错误改正;第 2处,应该是通过 BorderLayout布局管理器在窗口的最下方添加一个 JBuRon对象,需要清楚程序中每个对象所对应的类;第 3处,应该是将类 ex10_3的对象。obj10_3 加入容器中,而不是把类作为参数传递给 add()方法。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 13631-15-2005 Explosives for civil uses - High explosives - Part 15 Calculation of thermodynamic properties German version EN 13631-15 2005《民用爆炸物 烈性炸药 第15部分 热动力特性的计算》.pdf DIN EN 13631-15-2005 Explosives for civil uses - High explosives - Part 15 Calculation of thermodynamic properties German version EN 13631-15 2005《民用爆炸物 烈性炸药 第15部分 热动力特性的计算》.pdf
  • DIN EN 13631-16-2004 Explosives for civil uses - High explosives - Part 16 Detection and measurement of toxic gases German version EN 13631-16 2004《民用爆炸物 烈性炸药 第16部分 毒性气体的检测和测量》.pdf DIN EN 13631-16-2004 Explosives for civil uses - High explosives - Part 16 Detection and measurement of toxic gases German version EN 13631-16 2004《民用爆炸物 烈性炸药 第16部分 毒性气体的检测和测量》.pdf
  • DIN EN 13631-2-2002 Explosives for civil uses - High explosives - Part 2 Determination of thermal stability of explosives German version EN 13631-2 2002《民用爆炸物 高级炸药 第2部分 爆炸物热稳定性的测定 .pdf DIN EN 13631-2-2002 Explosives for civil uses - High explosives - Part 2 Determination of thermal stability of explosives German version EN 13631-2 2002《民用爆炸物 高级炸药 第2部分 爆炸物热稳定性的测定 .pdf
  • DIN EN 13631-3-2004 Explosives for civil uses - High explosives - Part 3 Determination of sensitiveness to friction of explosives German version EN 13631-3 2004《民用爆炸物 烈性炸药 第3部分 爆炸物.pdf DIN EN 13631-3-2004 Explosives for civil uses - High explosives - Part 3 Determination of sensitiveness to friction of explosives German version EN 13631-3 2004《民用爆炸物 烈性炸药 第3部分 爆炸物.pdf
  • DIN EN 13631-4-2002 Explosives for civil uses - High explosives - Part 4 Determination of sensitiveness to impact of explosives German version EN 13631-4 2002《民用爆炸物 高级炸药 第4部分 爆炸物冲击.pdf DIN EN 13631-4-2002 Explosives for civil uses - High explosives - Part 4 Determination of sensitiveness to impact of explosives German version EN 13631-4 2002《民用爆炸物 高级炸药 第4部分 爆炸物冲击.pdf
  • DIN EN 13631-5-2002 Explosives for civil uses - High explosives - Part 5 Determination of resistance to water German version EN 13631-5 2002《民用爆炸物 高级炸药 第5部分 抗水性的测定 德文版本 EN 13631-5 .pdf DIN EN 13631-5-2002 Explosives for civil uses - High explosives - Part 5 Determination of resistance to water German version EN 13631-5 2002《民用爆炸物 高级炸药 第5部分 抗水性的测定 德文版本 EN 13631-5 .pdf
  • DIN EN 13631-6-2002 en 7866 Explosives for civil uses - High explosives - Part 6 Determination of resistance to hydrostatic pressure German version EN 13631-6 2002《民用爆炸物 高级炸药 第6部分 .pdf DIN EN 13631-6-2002 en 7866 Explosives for civil uses - High explosives - Part 6 Determination of resistance to hydrostatic pressure German version EN 13631-6 2002《民用爆炸物 高级炸药 第6部分 .pdf
  • DIN EN 13631-7-2004 Explosives for civil uses - High explosives - Part 7 Determination of safety and reliability at extreme temperatures German version EN 13631-7 2003《民用爆炸物 烈性炸药 第.pdf DIN EN 13631-7-2004 Explosives for civil uses - High explosives - Part 7 Determination of safety and reliability at extreme temperatures German version EN 13631-7 2003《民用爆炸物 烈性炸药 第.pdf
  • DIN EN 13632-2010 Bitumen and bituminous binders - Visualisation of polymer dispersion in polymer modified bitumen German version EN 13632 2010《沥青和沥青粘合剂 高聚物改性沥青中高聚物分散的目测法 德文版本EN 13.pdf DIN EN 13632-2010 Bitumen and bituminous binders - Visualisation of polymer dispersion in polymer modified bitumen German version EN 13632 2010《沥青和沥青粘合剂 高聚物改性沥青中高聚物分散的目测法 德文版本EN 13.pdf
  • 相关搜索

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

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