【计算机类职业资格】计算机二级(JAVA)上机考试13及答案解析.doc

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

1、计算机二级(JAVA)上机考试 13 及答案解析(总分:-3.00,做题时间:90 分钟)1.基本操作题 下列程序中,实现将封装数据类型 Integer 和基本数据类型 int 之间的转换,以及Integer, int 类型和 String 类型之间的转换。请将程序补充完整。 程序运行结果如下: 123 456 456 public class ex7_1 public static void main(String args) Integer intObj; int n; String s; intObj=new Integer(123); n=intObj. ; System.out.pr

2、intln(Integer.toString(n); s=new String(“456“); intObj=Integer. ; System.out.println(intObj. ); n=Integer.parseInt(s); System.out.println(Integer.toString(n); (分数:-1.00)_2.简单应用题 请完成下列 Java 程序:创建一个具有 2 行 3 列的 GridLayout 管理器,包括Choice,Label,Button 构件,布局为第 1 行包括一个 Choice 构件(包括 2 个选项 item1 和 item2),一个Lab

3、el 构件(当选择 Choice 构件中的选项时,Label 构件显示相应的名称,即,如果点击 item1 则 Label中显示 item1),和一个 exit 按钮(点击则退出应用程序),第 2 行包括 3 个 Button 构件。程序运行结果如下: (分数:-1.00)_3.综合应用题 下面是一个 Applet 程序,其功能是将完整的图像显示于 Applet 的区块中,然后可以通过拖动鼠标让图像随着鼠标拖动的轨迹而移动。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。注意:不改动程序的结构,不得增行或删行。 程序运行结果如下: (分数:-1.00)_计算机二级(JAVA)上机

4、考试 13 答案解析(总分:-3.00,做题时间:90 分钟)1.基本操作题 下列程序中,实现将封装数据类型 Integer 和基本数据类型 int 之间的转换,以及Integer, int 类型和 String 类型之间的转换。请将程序补充完整。 程序运行结果如下: 123 456 456 public class ex7_1 public static void main(String args) Integer intObj; int n; String s; intObj=new Integer(123); n=intObj. ; System.out.println(Integer.

5、toString(n); s=new String(“456“); intObj=Integer. ; System.out.println(intObj. ); n=Integer.parseInt(s); System.out.println(Integer.toString(n); (分数:-1.00)_正确答案:(intValue() valueOf(s) toString() )解析:本题主要考查 Java 类库中对简单数据类型的封装以及对封装类型与基本类型之间的转换。解题关键是熟悉基本数据类型的封装,以及一些常用封装类型的常用转换方法,如 Integer 类的 parseInt()

6、方法等。本题中,第 1 个空,使用 intValue()方法将封装对象 intObj 转换为基本的数据类型 int;第 2 个空,使用 valueOf()方法,将字符串转换为封装对象 intObj;第 3 个空,使用 toString()方法,将封装对象 intObj 转换为字符串打印出来,注意,这里不可以加参数。2.简单应用题 请完成下列 Java 程序:创建一个具有 2 行 3 列的 GridLayout 管理器,包括Choice,Label,Button 构件,布局为第 1 行包括一个 Choice 构件(包括 2 个选项 item1 和 item2),一个Label 构件(当选择 Ch

7、oice 构件中的选项时,Label 构件显示相应的名称,即,如果点击 item1 则 Label中显示 item1),和一个 exit 按钮(点击则退出应用程序),第 2 行包括 3 个 Button 构件。程序运行结果如下: (分数:-1.00)_正确答案:(new GridLayout(2,3) addItemListener(this) )解析:本题主要考查 Java 常用构件 Choice 和高级事件 ItemEvent 以及 GridLayout 布局管理器的用法。解题关键是,熟悉 GridLayout 布局管理器和 ItemEvent 的用法。在本题中,ItemEvent 在教材

8、中并没有给出确切的用法,但是可以根据 ActionEvent 的 addActionEvent()方法和重载 actionPerformed()方法来完成对动作事件监听的用法来类推出 ItemEvent 事件的监听方法,这里要求有根据已有知识进行举一反三的能力。3.综合应用题 下面是一个 Applet 程序,其功能是将完整的图像显示于 Applet 的区块中,然后可以通过拖动鼠标让图像随着鼠标拖动的轨迹而移动。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。注意:不改动程序的结构,不得增行或删行。 程序运行结果如下: (分数:-1.00)_正确答案:(iImg = getImag

9、e(getDocumentBase(),“ex8_3.jpg“) g.drawImage(iImg,xPos,yPos,this) repaint() )解析:本题主要考查在 Applet 窗口中显示图像,并结合鼠标事件处理的综合应用。解题关键是熟悉图像文件的加载过程,会跟踪鼠标拖动的事件,并将鼠标在 Applet 窗口中的坐标信息作为参数传递给drawImage()方法,用于在新的位置显示图像,从而实现拖动效果。本题中,第一处,getImage()方法应该有 2 个参数,第一个参数是 getDocumentBase()方法的返回值,即图像文件的路径;第二处,drawImage()方法最后一个参数应该是 this,确定是在当前运行的对象中绘制图像;第三处,应该调用repaint()方法,进行重画,而不是 paint()方法。

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