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

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

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

2、 sumfenshu=0; int i=1; while(fenshu=60) import java.awt.event.*; public class BlueWindow public static void main(String args) Frame frm=new Frame (“欢迎参加 Java考试!“); TheAdapterTest listener=new TheAdapterTest(); frm. _; frm.setSize(200,200); frm.setBackground(Color.blue); frm. _; class TheAdapterTest

3、extends WindowAdapter public void windowClosing(WindowEvent e) System.exit(1); (分数:40.00)_三、B3综合应用题/B(总题数:1,分数:30.00)3.下面是一个 Applet程序,其功能是建立一个图形用户界面的窗口,包括一个文本显示区和一个按钮,单击按钮,可以在文本区已有的文本基础上追加显示 10条“欢迎您,参加 Java考试!”信息,并且文本区由滚动条控制文本的上下滚动。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 源程序文件代码清单如下; im

4、port javax.swing.*; import java.awt.*; import java.awt.event.*; applet code=“ex13_3.class“ width=800 height=400 /applet public class ex13_3 extends JApplet JButton jb = new JButton(“Add Text“); JTextPane jtp = new JTextPane(); public void init() jb.addActionListener(new ActionListener() public void

5、actionPerformed(ActionEvent e) for(int i=1; i10; i+) Ujtp.getText(jtp.setText()+/U U“欢迎您,参加 Java考试!“)/U; ); Container cp = getContentPane(); cp.add(new JScrollPane(jtp); Ucp.add(BorderLayout. SOUTH, jtp)/U; public static void main(String args) ex13_3 obj13_3=new ex13_3(); String str = obj13_3.getCla

6、ss().toString(); if(str.indexOf(“class“) !=-1) str=str.substring(6); JFrame frm = new JFrame(str); frm.addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent we) System.exit(0); ); Ufrm.getContentPane ().addiex13 3)/U; frm.setSize(300, 400); frm.setVisible(true); Bex13_3.html/B

7、HTML HEAD TITLEex13_3/TITLE /HEAD BODY applet code=“ex13_3.class“ width=800 height=400 /applet /BODY /HTML(分数:30.00)_二级 JAVA机试 81答案解析(总分:100.00,做题时间:90 分钟)一、B1基本操作题/B(总题数:1,分数:30.00)1.10位同学参加某团队测试,要求每位同学都必须及格,同时团队平均分不少于 80分,整个团队才能够通过。每位同学的成绩可以通过随机数产生(0100)。请在程序的每条横线处填写一条语句,使程序的功能完整。 注意;请勿改动 main()主方

8、法和其他已有的语句内容,仅在横线处填入适当的语句。 源程序文件代码清单如下: _; public class While public static void main(String args) int fenshu=60; int sumfenshu=0; int i=1; while(fenshu=60) import java.awt.event.*; public class BlueWindow public static void main(String args) Frame frm=new Frame (“欢迎参加 Java考试!“); TheAdapterTest liste

9、ner=new TheAdapterTest(); frm. _; frm.setSize(200,200); frm.setBackground(Color.blue); frm. _; class TheAdapterTest extends WindowAdapter public void windowClosing(WindowEvent e) System.exit(1); (分数:40.00)_正确答案:()解析:addWindowListener(listener) setVisible(true) 解析 本题主要考查窗体事件的处理机制。解答本题的关键是熟悉 Java语言的事件

10、处理机制(事件、事件源和事件处理者)。在本题中,frm.addWindowListener(listener);语句的功能是为窗体对象注册监听器;frm.setVisible (true)语句的功能是使生成的窗体具有可见性,若 frm.setVisible(false),则生成的窗体是不可见的。三、B3综合应用题/B(总题数:1,分数:30.00)3.下面是一个 Applet程序,其功能是建立一个图形用户界面的窗口,包括一个文本显示区和一个按钮,单击按钮,可以在文本区已有的文本基础上追加显示 10条“欢迎您,参加 Java考试!”信息,并且文本区由滚动条控制文本的上下滚动。请改正程序中的错误(

11、有下划线的语句),使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 源程序文件代码清单如下; import javax.swing.*; import java.awt.*; import java.awt.event.*; applet code=“ex13_3.class“ width=800 height=400 /applet public class ex13_3 extends JApplet JButton jb = new JButton(“Add Text“); JTextPane jtp = new JTextPane(); public void ini

12、t() jb.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) for(int i=1; i10; i+) Ujtp.getText(jtp.setText()+/U U“欢迎您,参加 Java考试!“)/U; ); Container cp = getContentPane(); cp.add(new JScrollPane(jtp); Ucp.add(BorderLayout. SOUTH, jtp)/U; public static void main(String args

13、) ex13_3 obj13_3=new ex13_3(); String str = obj13_3.getClass().toString(); if(str.indexOf(“class“) !=-1) str=str.substring(6); JFrame frm = new JFrame(str); frm.addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent we) System.exit(0); ); Ufrm.getContentPane ().addiex13 3)/U; fr

14、m.setSize(300, 400); frm.setVisible(true); Bex13_3.html/B HTML HEAD TITLEex13_3/TITLE /HEAD BODY applet code=“ex13_3.class“ width=800 height=400 /applet /BODY /HTML(分数:30.00)_正确答案:()解析:jtp.setText(jtp.qetText()+“欢迎您,参加 Java考试!/n”) cp.add(BorderLayout.SOUTH.jb) frm.getContentPane().add(obj13_3) 解析 本题

15、主要考查 Applet和 Swing结合进行图形用户界面设计的综合应用。解题关键是掌握 Swing的基本构件 JTextPanel,JButton, JScrollPanel 的用法,掌握BorderLayout布局管理器的使用方法,以及熟练掌握最基本的对象概念。本题中,第 1处,JTextPanel的两个基本方法,setText()和 getText(),熟悉这两个功能,则很容易就能将错误改正;第 2处,应该是通过 BorderLayout布局管理器在窗口的最下方添加一个 JButton对象,需要清楚程序中每个对象所对应的类;第 3处,应该是将类 ex13_3的对象。obj13_3 加入容器中,而不是把类作为参数传递给 add()方法。程序的输出结果如下。

展开阅读全文
相关资源
猜你喜欢
  • BS EN ISO 18563-1-2015 Non-destructive testing Characterization and verification of ultrasonic phased array equipment Instruments《无损试验 超声相控阵设备的特征和验证 仪器》.pdf BS EN ISO 18563-1-2015 Non-destructive testing Characterization and verification of ultrasonic phased array equipment Instruments《无损试验 超声相控阵设备的特征和验证 仪器》.pdf
  • BS EN ISO 18563-2-2017 Non-destructive testing Characterization and verification of ultrasonic phased array equipment Probes《无损检测 超声相控阵设备的鉴定和验证 探头》.pdf BS EN ISO 18563-2-2017 Non-destructive testing Characterization and verification of ultrasonic phased array equipment Probes《无损检测 超声相控阵设备的鉴定和验证 探头》.pdf
  • BS EN ISO 18592-2009 Resistance welding - Destructive testing of welds - Method for the fatigue testing of multispot- welded specimens《电阻焊接 焊接破坏性试验 多点疲劳试验方法 焊接样本》.pdf BS EN ISO 18592-2009 Resistance welding - Destructive testing of welds - Method for the fatigue testing of multispot- welded specimens《电阻焊接 焊接破坏性试验 多点疲劳试验方法 焊接样本》.pdf
  • BS EN ISO 18594-2007 Resistance spot- projection- and seam-welding - Method for determining the transition resistance on aluminium and steel material《电阻点焊、凸焊和缝隙焊接 测定铝和钢材料跃迁电阻的方法》.pdf BS EN ISO 18594-2007 Resistance spot- projection- and seam-welding - Method for determining the transition resistance on aluminium and steel material《电阻点焊、凸焊和缝隙焊接 测定铝和钢材料跃迁电阻的方法》.pdf
  • BS EN ISO 18595-2007 Resistance welding - Spot welding of aluminium and aluminium alloys - Weldability welding and testing《电阻焊接 铝和铝合金的点焊 可焊性、焊接和测试》.pdf BS EN ISO 18595-2007 Resistance welding - Spot welding of aluminium and aluminium alloys - Weldability welding and testing《电阻焊接 铝和铝合金的点焊 可焊性、焊接和测试》.pdf
  • BS EN ISO 18609-2001 Animal and vegetable fats and oils Determination of unsaponifiable matter Method using hexane extraction《动植物油脂 非皂化物测定 己烷提取法》.pdf BS EN ISO 18609-2001 Animal and vegetable fats and oils Determination of unsaponifiable matter Method using hexane extraction《动植物油脂 非皂化物测定 己烷提取法》.pdf
  • BS EN ISO 18613-2014 Pallets for materials handling Repair of flat wooden pallets《材料搬运用托盘 木制平托盘的修理》.pdf BS EN ISO 18613-2014 Pallets for materials handling Repair of flat wooden pallets《材料搬运用托盘 木制平托盘的修理》.pdf
  • BS EN ISO 18635-2016 Water quality Determination of short-chain polychlorinated alkanes (SCCPs) in sediment sewage sludge and suspended (particulate) matter Method using gas chromac.pdf BS EN ISO 18635-2016 Water quality Determination of short-chain polychlorinated alkanes (SCCPs) in sediment sewage sludge and suspended (particulate) matter Method using gas chromac.pdf
  • BS EN ISO 18674-1-2015 Geotechnical investigation and testing Geotechnical monitoring by field instrumentation General rules《岩土工程勘察和试验 采用现场仪表的岩土工程监测 通用规则》.pdf BS EN ISO 18674-1-2015 Geotechnical investigation and testing Geotechnical monitoring by field instrumentation General rules《岩土工程勘察和试验 采用现场仪表的岩土工程监测 通用规则》.pdf
  • 相关搜索

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

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