[计算机类试卷]国家二级(JAVA)机试模拟试卷79及答案与解析.doc

上传人:赵齐羽 文档编号:503615 上传时间:2018-11-29 格式:DOC 页数:3 大小:39.50KB
下载 相关 举报
[计算机类试卷]国家二级(JAVA)机试模拟试卷79及答案与解析.doc_第1页
第1页 / 共3页
[计算机类试卷]国家二级(JAVA)机试模拟试卷79及答案与解析.doc_第2页
第2页 / 共3页
[计算机类试卷]国家二级(JAVA)机试模拟试卷79及答案与解析.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

1、国家二级( JAVA)机试模拟试卷 79及答案与解析 一、基本操作题( 30分) 1 下列程序中,指定变量 b=20为字节类型,变量 f=0.34F为单精度类型,变量1=0xeefL为 64位长整型,并将该三个变量打印输出。请将程序补充完整。 注意:不改动程序结构,不得增行或删行。 import java.io.*; public class Assign public static void main(String args ) _b=20; _f=0.34F; _l=0xeefL; System.out.println(“b=“+b); System.out.println(“f=“+f)

2、 System.out.println(“l=“+1); 二、简单应用题( 40分) 2 下列程序建立一个 file.dat的文件,并且允许按照不同的数据类型向里面输入数据,请将程序补充完整。 注 意:不改动程序结构,不得增行或删行。 package ch3; import java.io.*; public class Test public static void main(String args) try _fos=new_(“ch3/file.dat“); _ catch(IOException ioe) ioe.printStackTrace(); 三、综合应用题( 30分) 3

3、下面是一个 Applet程序,其功能是有 2个按钮,分别为 First和 Second,以及一个 Label构件。要求单击 First时则能在 Label中显示出 Command: First,而单击Second时则能显示出 Command: Second,要求只能使用重载一次 actionPerformed()方法。请改正 程序中的错误 (有下划线的语句 ),使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 程序运行结果如下: import java.awt.*; import java.awt.event.*; import java.applet.*; /* apple

4、t code=ex3_3.class width=800 height=400 /applet */ public class ex3_3 extends Applet implements ActionListener private String str=“ok“; private Label 1; private Button btn; public void init( ) setLayout(null); 1=new Label(str); 1.reshape(10,10,150,30); add(1); btn=new Button(“First“); btn.reshape(10

5、50,60,20); 1.addActionListener(this); add(btn); btn=new Button(“Second“); btn.reshape(10,100,60,20); btn.setActionCommand(“First“); btn.addActionListener(this); add(btn); public void actionPerformed(ActionEvent ae) str=“Command:“+ae.getActionCommand( ); btn.setText(str); ex3_3.html HTML HEAD TITLE

6、ex3_3 /TITLE /HEAD BODY applet code=“ex3_3.class“width=800 height=400 /applet /BODY /HTML 国家二级( JAVA)机试模拟试卷 79答案与解析 一、基本操作题( 30分) 1 【正确答案】 byte float long 【试题解析】 本题考查处理基本数据类型的声明。定义一个变量需要有一个类型,一个标识,如果需要,还可以加上一个初始值。本题涉及到三种类型:字节整型、单精度浮点型和 64位的长整型,分别 用关键字 byte、 float和 long标识。 二、简单应用题( 40分) 2 【正确答案】 File

7、OutputStream FileOutputStream DataOutputStream dos=new DateOutputStream(fos); 【试题解析】 本题考查 Java语言的输入输出流,这是一道简单应用题。这里用文件输出流 FileOutputStream创建向文件 file.txt中写入字节数据的输出流。允许按照不同数据类型进行输出,应该使用 DataOutputStream流,并且要使用FileOutputStream类的对象 fos作为该类的构造方法的参数。因此, 3个空的答案分别是 FileOutputStream、 FileOutputStream、 DataOu

8、tputStream dos=new DateOutputStream(fos);。 三、综合应用题( 30分) 3 【正确答案】 Btn.addActionListener(this) Btn.setActionCommand(“second”) 1.setText(str) 【试题解析】 本 题主要考查 Java语言中高级事件 ActionEvent和 AWT基本构件Label的常用方法的使用。解题关键是熟练掌握动作事件 ActionEvent和 Label构件的常用方法。在本题中,第 1处,明确注册的事件监听器是监听按钮的,而不是 Label的;第 2处,调用 ActionEvent的 setActionCommand()方法改变了ActionCommand,使按下第二个按钮时显示 Command: second而不是 Command: First。第 3处,调用 Label的 setText()方法,而不是 Button的 方法。

展开阅读全文
相关资源
猜你喜欢
  • BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf BS PD IEC TS 62763-2013_5284 Pilot function through a control pilot circuit using PWM (pulse width modulation) and a control pilot wire《通过控制导向线使用PWM (脉冲宽度调制) 的导向功能和控制导向线》.pdf
  • BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf BS ISO 8070-2007 Milk and milk products - Determination of calcium sodium potassium and magnesium contents - Atomic absorption spectrometric method《牛奶和奶制品 钙、钠、钾和镁含量的测定 原子吸.pdf
  • BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf BS ISO 8082-1-2009 Self-propelled machinery for forestry - Laboratory tests and performance requirements for roll-over protective structures - General machines《林业用自推进机械 防倾.pdf
  • BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf BS ISO 8082-2-2011 Self-propelled machinery for forestry Laboratory tests and performance requirements for roll-over protective structures Machines having a rotating platf.pdf
  • BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf BS ISO 8083-2006 Machinery for forestry - Falling-object protective structures (FOPS) - Laboratory tests and performance requirements《林业机械 落体防护装置(FOPS) 实验室试验和性能要求》.pdf
  • BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf BS ISO 8086-2004 Dairy plant - Hygiene conditions - General guidance on inspection and sampling procedures《乳品厂 卫生条件 检验和取样程序通用指南》.pdf
  • BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf BS ISO 8096-2005 Rubber- or plastics-coated fabrics for water resistant clothing - Specification《雨衣用橡胶或塑料涂覆织物 规范》.pdf
  • BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf BS ISO 8097-2001 Aircraft Minimum airworthiness requirements and test conditions for certified air cargo unit load devices《航空器 经认证的航空货运集装单元装置最低适航性要求和试验条件》.pdf
  • BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf BS ISO 8114-1993 Textile machinery and accessories - Spindles for ring-spinning and doubling machines - List of equivalent terms《纺织机械和附件 环锭纺纱机和并线机用锭子 同义术语表》.pdf
  • 相关搜索

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

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