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

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

1、国家二级( JAVA)机试模拟试卷 28及答案与解析 一、基本操作题( 30分) 1 下列 Applet程序中,指定 s为字符串类型,将 s绘制在屏幕上,请将程序补充完整。 import java applet Applet; import java awt Craphics; public class testl8_1 extends Applet _String s; public void init () s=new String(“Hello World“); public Void_(Graphics g) g._(s, 10, 25); 二、简单应用题( 40分) 2 下面程序代码

2、让用户输入想显示的 gif文件名,之后将这个图像文件加载到内存并显示。请勿改动原有代码,在下画线处填人适当浯句,将程序补充完整。 import java applet *; import java awt *; import java awt event *; public class test20_2 extends Applet implements ActionListener Label promptLbl=new Label(“请输入欲显示的图像文件名: ”); TextField inputTfd=new TextField20( ); Button getlmageBtn=ne

3、w Button(“显示图像 ”); Image mylmage; public void init( ) add(promptLbl); add(inputTfd); add(getlmageBtn); inputTfd setText(”); getlmageBtn addActionListener(this); public void paint(Graphics g) if(mylmage!=null) g._(mylmage, 10, 100, this); public void actionPerformed(ActionEvent ae) if(ae getSource( )

4、) String str=inputTfd getText( ) trim( ); if(!(str substring(Math max(0, str length( )-4) equals(“.gif“) str=str trim( )+“ gif“; mylmage=getlmage(getDocumentBase( ), str); repaint( ); 三、综合应用题( 30分) 3 下面是一个 Applet程序,其功能是进行整数加法运算,要求有 3个文本区域, 2个作为输入, 1个作为输出,并且由异常处理来判断输入的数字是否为整型,如果是则进行运算,否则抛出异常并显示在第 3

5、个文本区域中。请改正程序中的错误(有下画线的语句 ),使程序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 import java awt *; impoat java awt event *; impoat java applet Applet; /* */ public class exl7_3 extends Applet implements ActionListener TextField tfl=new TextField(5); TextField tf2=new TextField(5); TextField tf3=newTextField(5); Label

6、11=new Label(“+“); Label l2=new Label(“=“); Button btn=new Button(“add“); public void init( ) add(11); add(tf1); add(tf2); add(12); add(tf3); add(btn); btn addActionListener(this); public void actionPerformed(ActionEvent ae) try int a=Integer parseInt(tf1 getText(); int b=Integer parseInt(tf2 getTex

7、t(); int x=a+b; tf2 setText(Integer toString(x); catch(NumberFormatException nfe) tf3 setText(“error!“); ex19_3 html HTML HEAD TITLE exl9_3 /TITLE /HEAD BODY applet code=“ex19_3.clasS“width=800 height=400 /applet /BODY /HTML 国家二级( JAVA)机试模拟试卷 28答案与解析 一、基本操作题( 30分) 1 【正确答案】 public,paint, drawString 二、简单应用题( 40分) 2 【正确答案】 drawlmage getlmageBtn 三、综合应用题( 30分) 3 【正确答案】 add(tf1) add(11) tf3 setText(Integer toString(x)

展开阅读全文
相关资源
猜你喜欢
  • 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