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

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

1、二级 JAVA 机试 53 及答案解析(总分:100.00,做题时间:90 分钟)一、B1基本操作题/B(总题数:1,分数:30.00)1.下面程序的功能是显示已定义的一个 3 行 3 列的二维数组每行的元素,并求所有元素的和并输出。请在程序的每条横线处填写一个适当的语句,使程序的功能完整。 public class ShuZu public static void main(String args) int sam=0; int b=13,14,15,23,24,25,33,34,35; for(int i=0;_ i+) System.out.print(“b“+i+“: “); for(

2、int j=0;_ j+) System.out.print(bij+“); _ System.out.println(); System.out.println(“sum=“+sum); (分数:30.00)_二、B2简单应用题/B(总题数:1,分数:40.00)2.请完成下列 Java 程序。程序的执行结果是生成一个具有一个 TextField 类型的对象 in、But ton 类型的对象 btn 和 Label 类型的对象 out 图形用户界面,程序的功能是计算用户输入数的平方。 注意:请勿改动 main()主方法和其他已有的语句内容,仅在下画线处填人适当的语句。 import java

3、awt.*; import java.awt.event.*; public class PingFangShu public static void main(String args) _ class AppFrame extends Frame TheAdapterTest listener=new TheAdapterTest(); TextField in=new TextField(5); Button btn=new Button(“计算“); Label out=new Label(“显示计算结果“); public AppFrame() setLayout(new FlowL

4、ayout(); add(in); add(btn); add(out); btn.addActionListener(new BtnActionAdapter(); addWindowListener(listener); setSize(400,100); show(); class BtnActionAdapter implements ActionListener public void actionPerformed(ActionEvent e) String s=in.getText(); double d=_ double sq=d*d; out.setText(d+“的平方是:

5、sq); class TheAdapterTest extends WindowAdapter public void windowClosing(WindowEvent e) System.exit(1); (分数:40.00)_三、B3综合应用题/B(总题数:1,分数:30.00)3.下面 Applet 程序的功能是统计在平面坐标系第一象限中,半径大于 9,小于 10 的圆环中坐标值为整数的点有多少?并且给出其坐标值。请改正程序中的错误(有下画线的语句),使程序执行后,能得到预期的结果。 import java.awt.*; import java.applet.*; /* apple

6、t code=Di9Ti width=200 height=100 /applet */ public class Di9Ti extends Applet public void paint(Graphics g) int x,y,r1=5,r2=4; int count=0; for(x=1;xy;x+) for(y=1;yr1;y) if(x*x+y*y=r2*r2|x*x+y*y=r1*r1) Ubreak/U; g.drawStdng(“x=“+x+“y=“+y,20+count*80,20); count+; g.drawString(“count=“+count,20,40);

7、ex11_3.html: html head titleA Simple Program/title /head body applet code=“Di9Ti.class“width=800 height=400 /applet body html(分数:30.00)_二级 JAVA 机试 53 答案解析(总分:100.00,做题时间:90 分钟)一、B1基本操作题/B(总题数:1,分数:30.00)1.下面程序的功能是显示已定义的一个 3 行 3 列的二维数组每行的元素,并求所有元素的和并输出。请在程序的每条横线处填写一个适当的语句,使程序的功能完整。 public class ShuZu

8、 public static void main(String args) int sam=0; int b=13,14,15,23,24,25,33,34,35; for(int i=0;_ i+) System.out.print(“b“+i+“: “); for(int j=0;_ j+) System.out.print(bij+“); _ System.out.println(); System.out.println(“sum=“+sum); (分数:30.00)_正确答案:()解析:length; jbi.length; sum+=bij;二、B2简单应用题/B(总题数:1,分数

9、40.00)2.请完成下列 Java 程序。程序的执行结果是生成一个具有一个 TextField 类型的对象 in、But ton 类型的对象 btn 和 Label 类型的对象 out 图形用户界面,程序的功能是计算用户输入数的平方。 注意:请勿改动 main()主方法和其他已有的语句内容,仅在下画线处填人适当的语句。 import java.awt.*; import java.awt.event.*; public class PingFangShu public static void main(String args) _ class AppFrame extends Frame

10、TheAdapterTest listener=new TheAdapterTest(); TextField in=new TextField(5); Button btn=new Button(“计算“); Label out=new Label(“显示计算结果“); public AppFrame() setLayout(new FlowLayout(); add(in); add(btn); add(out); btn.addActionListener(new BtnActionAdapter(); addWindowListener(listener); setSize(400,1

11、00); show(); class BtnActionAdapter implements ActionListener public void actionPerformed(ActionEvent e) String s=in.getText(); double d=_ double sq=d*d; out.setText(d+“的平方是:“+sq); class TheAdapterTest extends WindowAdapter public void windowClosing(WindowEvent e) System.exit(1); (分数:40.00)_正确答案:()解

12、析:new AppFrame(); Double.parseDouble(s);三、B3综合应用题/B(总题数:1,分数:30.00)3.下面 Applet 程序的功能是统计在平面坐标系第一象限中,半径大于 9,小于 10 的圆环中坐标值为整数的点有多少?并且给出其坐标值。请改正程序中的错误(有下画线的语句),使程序执行后,能得到预期的结果。 import java.awt.*; import java.applet.*; /* applet code=Di9Ti width=200 height=100 /applet */ public class Di9Ti extends Applet

13、 public void paint(Graphics g) int x,y,r1=5,r2=4; int count=0; for(x=1;xy;x+) for(y=1;yr1;y) if(x*x+y*y=r2*r2|x*x+y*y=r1*r1) Ubreak/U; g.drawStdng(“x=“+x+“y=“+y,20+count*80,20); count+; g.drawString(“count=“+count,20,40); ex11_3.html: html head titleA Simple Program/title /head body applet code=“Di9Ti.class“width=800 height=400 /applet body html(分数:30.00)_正确答案:()解析:xr1; y+ continue;

展开阅读全文
相关资源
猜你喜欢
  • EN 16292-2013 en Glass packaging - Screw finishes - Depressed threads《玻璃包装 螺纹瓶口 凹螺纹》.pdf EN 16292-2013 en Glass packaging - Screw finishes - Depressed threads《玻璃包装 螺纹瓶口 凹螺纹》.pdf
  • EN 16293-2013 en Packaging - Glass Packaging - Deep BVS finishes for still wines《包装 玻璃包装 无气葡萄酒瓶用深度BVS抛光》.pdf EN 16293-2013 en Packaging - Glass Packaging - Deep BVS finishes for still wines《包装 玻璃包装 无气葡萄酒瓶用深度BVS抛光》.pdf
  • EN 16296-2012 en Imperfections in thermoplastics welded joints - Quality levels《热塑性塑料焊缝瑕疵 质量等级》.pdf EN 16296-2012 en Imperfections in thermoplastics welded joints - Quality levels《热塑性塑料焊缝瑕疵 质量等级》.pdf
  • EN 16297-1-2012 en Pumps - Rotodynamic pumps - Glandless circulators - Part 1 General requirements and procedures for testing and calculation of energy efficiency index (EEI)《泵 旋转动.pdf EN 16297-1-2012 en Pumps - Rotodynamic pumps - Glandless circulators - Part 1 General requirements and procedures for testing and calculation of energy efficiency index (EEI)《泵 旋转动.pdf
  • EN 16297-2-2012 en Pumps - Rotodynamic pumps - Glandless circulators - Part 2 Calculation of energy efficiency index (EEI) for standalone circulators《泵 旋转动力泵 无密封垫的循环器 单机循环器的能源效率指数(.pdf EN 16297-2-2012 en Pumps - Rotodynamic pumps - Glandless circulators - Part 2 Calculation of energy efficiency index (EEI) for standalone circulators《泵 旋转动力泵 无密封垫的循环器 单机循环器的能源效率指数(.pdf
  • EN 16297-3-2012 en Pumps - Rotodynamic pumps - Glandless circulators - Part 3 Energy efficiency index (EEI) for circulators integrated in products《泵 转子动力泵 无填料循环器 第3部分 产品集成循环器的能源效率指.pdf EN 16297-3-2012 en Pumps - Rotodynamic pumps - Glandless circulators - Part 3 Energy efficiency index (EEI) for circulators integrated in products《泵 转子动力泵 无填料循环器 第3部分 产品集成循环器的能源效率指.pdf
  • EN 16299-2013 en Cathodic protection of external surfaces of above ground storage tank bases in contact with soil or foundations《与土壤或地基接触的地面储罐基底外表面的阴极保护》.pdf EN 16299-2013 en Cathodic protection of external surfaces of above ground storage tank bases in contact with soil or foundations《与土壤或地基接触的地面储罐基底外表面的阴极保护》.pdf
  • EN 16301-2013 en Natural stone test methods - Determination of sensitivity to accidental staining《天然石料试验方法 偶然染色灵敏度的测定》.pdf EN 16301-2013 en Natural stone test methods - Determination of sensitivity to accidental staining《天然石料试验方法 偶然染色灵敏度的测定》.pdf
  • EN 16302-2013 en Conservation of cultural heritage - Test methods - Measurement of water absorption by pipe method《保护文化遗产 测试方法测量的吸水管的方法》.pdf EN 16302-2013 en Conservation of cultural heritage - Test methods - Measurement of water absorption by pipe method《保护文化遗产 测试方法测量的吸水管的方法》.pdf
  • 相关搜索

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

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