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

上传人:unhappyhay135 文档编号:1326446 上传时间:2019-10-17 格式:DOC 页数:7 大小:35.50KB
下载 相关 举报
【计算机类职业资格】二级JAVA机试-115及答案解析.doc_第1页
第1页 / 共7页
【计算机类职业资格】二级JAVA机试-115及答案解析.doc_第2页
第2页 / 共7页
【计算机类职业资格】二级JAVA机试-115及答案解析.doc_第3页
第3页 / 共7页
【计算机类职业资格】二级JAVA机试-115及答案解析.doc_第4页
第4页 / 共7页
【计算机类职业资格】二级JAVA机试-115及答案解析.doc_第5页
第5页 / 共7页
点击查看更多>>
资源描述

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

2、enshu=0;int i=1;while(fenshu=60)import java.awt.event.*;public class BlueWindowpublic 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 extends WindowAd

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

4、ort java.awt.*;import java.awt.event.*;applet code=“ex13_3.class“ width=800 height=400/appletpublic class ex13_3 extends JAppletJButton jb = new JButton(“Add Text“);JTextPane jtp = new JTextPane();public void init()jb.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)fo

5、r(int i=1; i10; i+)jtp.getText(jtp.setText()+“欢迎您,参加 Java 考试!“););Container cp = getContentPane();cp.add(new JScrollPane(jtp);cp.add(BorderLayout. SOUTH, jtp);public static void main(String args)ex13_3 obj13_3=new ex13_3();String str = obj13_3.getClass().toString();if(str.indexOf(“class“) !=-1)str=s

6、tr.substring(6);JFrame frm = new JFrame(str);frm.addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent we)System.exit(0););frm.getContentPane ().addiex13 3);frm.setSize(300, 400);frm.setVisible(true);ex13_3.htmlHTMLHEADTITLEex13_3/TITLE/HEADBODYapplet code=“ex13_3.class“ width=8

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

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

9、 _;class TheAdapterTest extends WindowAdapterpublic void windowClosing(WindowEvent e)System.exit(1);(分数:40.00)_正确答案:(addWindowListener(listener)setVisible(true)解析:解析 本题主要考查窗体事件的处理机制。解答本题的关键是熟悉 Java 语言的事件处理机制(事件、事件源和事件处理者)。在本题中,frm.addWindowListener(listener);语句的功能是为窗体对象注册监听器;frm.setVisible (true)语句的

10、功能是使生成的窗体具有可见性,若 frm.setVisible(false),则生成的窗体是不可见的。三、3综合应用题(总题数:1,分数:30.00)3.下面是一个 Applet 程序,其功能是建立一个图形用户界面的窗口,包括一个文本显示区和一个按钮,单击按钮,可以在文本区已有的文本基础上追加显示 10 条“欢迎您,参加 Java 考试!”信息,并且文本区由滚动条控制文本的上下滚动。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。注意:不改动程序的结构,不得增行或删行。源程序文件代码清单如下;import javax.swing.*;import java.awt.*;impor

11、t java.awt.event.*;applet code=“ex13_3.class“ width=800 height=400/appletpublic class ex13_3 extends JAppletJButton jb = new JButton(“Add Text“);JTextPane jtp = new JTextPane();public void init()jb.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e)for(int i=1; i10; i+)j

12、tp.getText(jtp.setText()+“欢迎您,参加 Java 考试!“););Container cp = getContentPane();cp.add(new JScrollPane(jtp);cp.add(BorderLayout. SOUTH, jtp);public static void main(String args)ex13_3 obj13_3=new ex13_3();String str = obj13_3.getClass().toString();if(str.indexOf(“class“) !=-1)str=str.substring(6);JFra

13、me frm = new JFrame(str);frm.addWindowListener(new WindowAdapter()public void windowClosing(WindowEvent we)System.exit(0););frm.getContentPane ().addiex13 3);frm.setSize(300, 400);frm.setVisible(true);ex13_3.htmlHTMLHEADTITLEex13_3/TITLE/HEADBODYapplet code=“ex13_3.class“ width=800 height=400/applet

14、/BODY/HTML(分数:30.00)_正确答案:(jtp.setText(jtp.qetText()+“欢迎您,参加 Java 考试!/n”)cp.add(BorderLayout.SOUTH.jb)frm.getContentPane().add(obj13_3)解析:解析 本题主要考查 Applet 和 Swing 结合进行图形用户界面设计的综合应用。解题关键是掌握Swing 的基本构件 JTextPanel,JButton, JScrollPanel 的用法,掌握 BorderLayout 布局管理器的使用方法,以及熟练掌握最基本的对象概念。本题中,第 1 处,JTextPanel 的两个基本方法,setText()和getText(),熟悉这两个功能,则很容易就能将错误改正;第 2 处,应该是通过 BorderLayout 布局管理器在窗口的最下方添加一个 JButton 对象,需要清楚程序中每个对象所对应的类;第 3 处,应该是将类ex13_3 的对象。obj13_3 加入容器中,而不是把类作为参数传递给 add()方法。程序的输出结果如下。*

展开阅读全文
相关资源
猜你喜欢
  • GOST R 7 0 6-2008 System of standards on information librarianship and publishing International standard number for musical edition Publishing design and use《信息、图书管理和出版标准系统 音乐版本用国际.pdf GOST R 7 0 6-2008 System of standards on information librarianship and publishing International standard number for musical edition Publishing design and use《信息、图书管理和出版标准系统 音乐版本用国际.pdf
  • GOST R 7 0 61-2011 System of standards on information librarianship and publishing Current national bibliographical indices General requirements and publishing presentation《信息、图书馆和.pdf GOST R 7 0 61-2011 System of standards on information librarianship and publishing Current national bibliographical indices General requirements and publishing presentation《信息、图书馆和.pdf
  • GOST R 7 0 66-2010 System of standards on information librarianship and publishing Indexing of documents General requirements for coordinate indexing《文件材料 检查文件 确定文件主题和选择索引词的方法》.pdf GOST R 7 0 66-2010 System of standards on information librarianship and publishing Indexing of documents General requirements for coordinate indexing《文件材料 检查文件 确定文件主题和选择索引词的方法》.pdf
  • GOST R 7 0 7-2009 System of standards on information librarianship and publishing Articles in journals and collections Publisher-s presentation《信息、图书管理和出版标准系统 期刊和收藏论文 出版商描述》.pdf GOST R 7 0 7-2009 System of standards on information librarianship and publishing Articles in journals and collections Publisher-s presentation《信息、图书管理和出版标准系统 期刊和收藏论文 出版商描述》.pdf
  • GOST R 7 0 8-2013 System of standards on information librarianship and publishing Records management and organization of archives Terms and difinitions《信息 图书馆事业和出版的标准系统 记录管理和档案组织 术.pdf GOST R 7 0 8-2013 System of standards on information librarianship and publishing Records management and organization of archives Terms and difinitions《信息 图书馆事业和出版的标准系统 记录管理和档案组织 术.pdf
  • GOST R 7 0 83-2013 System of standards on information librarianship and publishing Electronic editions Basic types and imprints《信息 图书管理和出版标准体系 电子版 基本类型和印记》.pdf GOST R 7 0 83-2013 System of standards on information librarianship and publishing Electronic editions Basic types and imprints《信息 图书管理和出版标准体系 电子版 基本类型和印记》.pdf
  • GOST R 7 0 9-2009 System of standards on information librarianship and publishing Bibliographic coverage for publishing and bookselling processes General requirements《信息 图书管理和出版标准系.pdf GOST R 7 0 9-2009 System of standards on information librarianship and publishing Bibliographic coverage for publishing and bookselling processes General requirements《信息 图书管理和出版标准系.pdf
  • GOST R 8 1558-1993 State system for ensuring the uniformity of measurements State verification schedule for 1 to 1·10 minus 3 degree V m2 degree irradiance Measuring means within t.pdf GOST R 8 1558-1993 State system for ensuring the uniformity of measurements State verification schedule for 1 to 1·10 minus 3 degree V m2 degree irradiance Measuring means within t.pdf
  • GOST R 8 559-1994 State system for ensuring the uniformity of measurements Measuring lasers Method for verification《国家测量统一性保证体系 测量激光器 鉴定方法》.pdf GOST R 8 559-1994 State system for ensuring the uniformity of measurements Measuring lasers Method for verification《国家测量统一性保证体系 测量激光器 鉴定方法》.pdf
  • 相关搜索

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

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