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

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

1、计算机二级(JAVA)上机考试 24 及答案解析(总分:-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 程序,其功能是有 2 个按钮,分别为 First 和 Second,以及一个 Label构件。要求点击 First 时则能在 Label 中显示出 Command:First,而点击 Second 时则能显示出Command:Second,要求只能使用重载一次 actionPerf

4、ormed()方法。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。程序运行结果如下: (分数:-1.00)_计算机二级(JAVA)上机考试 24 答案解析(总分:-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;

5、 String s; intObj=new Integer(123); n=intObj. ; System.out.println(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)_正确答案:(intValue() valueOf(s) toString() )解析:本题主要考查 Java 类库中对简单数据类型的封装以

6、及对封装类型与基本类型之间的转换。解题关键是熟悉基本数据类型的封装,以及一些常用封装类型的常用转换方法,如 Integer 类的 parseInt()方法等。本题中,第 1 个空,使用 intValue()方法将封装对象 intObj 转换为基本的数据类型 int;第 2 个空,使用 valueOf()方法,将字符串转换为封装对象 intObj;第 3 个空,使用 toString()方法,将封装对象 intObj 转换为字符串打印出来,注意,这里不可以加参数。2.简单应用题 请完成下列 Java 程序:创建一个具有 2 行 3 列的 GridLayout 管理器,包括Choice,Label

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

8、Layout 布局管理器的用法。解题关键是,熟悉 GridLayout 布局管理器和 ItemEvent 的用法。在本题中,ItemEvent 在教材中并没有给出确切的用法,但是可以根据 ActionEvent 的 addActionEvent()方法和重载 actionPerformed()方法来完成对动作事件监听的用法来类推出 ItemEvent 事件的监听方法,这里要求有根据已有知识进行举一反三的能力。3.综合应用题 下面是一个 Applet 程序,其功能是有 2 个按钮,分别为 First 和 Second,以及一个 Label构件。要求点击 First 时则能在 Label 中显示出

9、 Command:First,而点击 Second 时则能显示出Command:Second,要求只能使用重载一次 actionPerformed()方法。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。程序运行结果如下: (分数:-1.00)_正确答案:(btn.addActionListener(this) btn.setActionCommand(“second“) l.setText(str) )解析:本题主要考查 Java 语言中高级事件 ActionEvent 和 AWT 基本构件 Label 的常用方法的使用。解题关键是熟练掌握动作事件 ActionEvent 和 Label 构件的常用方法。在本题中,第 1 处,明确注册的事件监听器是监听按钮的,而不是 Label 的;第 2 处,调用 ActionEvent 的 setActionCommand()方法改变了ActionCommand,使按下第二个按钮时显示 Command:second 而不是 Command: First。第 3 处,调用 Label的 setText()方法,而不是 Button 的方法。

展开阅读全文
相关资源
猜你喜欢
  • NF C97-102-3-1993 Helical-scan video tape cassette system using 8 mm magnetic tape 8 mm video Part 3  high-band specifications for hi 8 《使用 8 mm 磁带及 8 mm 录像带的螺旋扫描盒式录像带系统 第3部分 HI 8 .pdf NF C97-102-3-1993 Helical-scan video tape cassette system using 8 mm magnetic tape 8 mm video Part 3 high-band specifications for hi 8 《使用 8 mm 磁带及 8 mm 录像带的螺旋扫描盒式录像带系统 第3部分 HI 8 .pdf
  • NF C97-103-1990 Recording and reproduction of sound and video Method of measurement of speed fluctuations in sound recording and reproducing equipment 《声像录放 声音录放设备中速度波动的测量方法》.pdf NF C97-103-1990 Recording and reproduction of sound and video Method of measurement of speed fluctuations in sound recording and reproducing equipment 《声像录放 声音录放设备中速度波动的测量方法》.pdf
  • NF C97-104-1993 Videodisks Methods of measurement for parameters 《视盘 参数的测量方法》.pdf NF C97-104-1993 Videodisks Methods of measurement for parameters 《视盘 参数的测量方法》.pdf
  • NF C97-105-1-2005 Helical-scan digital video cassette recording system using 12 65 mm (0 5 in) magnetic tape - Format HD-D5 - Part 1  VTR specifications 《使用12 65mm(0 5in)磁带的螺旋扫描数字视.pdf NF C97-105-1-2005 Helical-scan digital video cassette recording system using 12 65 mm (0 5 in) magnetic tape - Format HD-D5 - Part 1 VTR specifications 《使用12 65mm(0 5in)磁带的螺旋扫描数字视.pdf
  • NF C97-105-2-2005 Helical-scan digital video cassette recording system using 12 65 mm (0 5 in) magnetic tape - Format HD-D5 - Part 2  compression format 《使用12 65mm(0 5in)磁带的螺旋扫描数字视.pdf NF C97-105-2-2005 Helical-scan digital video cassette recording system using 12 65 mm (0 5 in) magnetic tape - Format HD-D5 - Part 2 compression format 《使用12 65mm(0 5in)磁带的螺旋扫描数字视.pdf
  • NF C97-105-3-2005 Helical-scan digital video cassette recording system using 12 65 mm (0 5 in) magnetic tape - Format HD-D5 - Part 3  data stream format 《使用12 65mm(0 5in)磁带的螺旋扫描数字视.pdf NF C97-105-3-2005 Helical-scan digital video cassette recording system using 12 65 mm (0 5 in) magnetic tape - Format HD-D5 - Part 3 data stream format 《使用12 65mm(0 5in)磁带的螺旋扫描数字视.pdf
  • NF C97-131-1989 Recording and reproduction of sound and video Analogue audio disk records and reproducing equipment 《音像录制和复制 摸拟录音盘及复制设备》.pdf NF C97-131-1989 Recording and reproduction of sound and video Analogue audio disk records and reproducing equipment 《音像录制和复制 摸拟录音盘及复制设备》.pdf
  • NF C97-132-1999 Audio recording Compact disc digital audio system 《音频录制 光盘数字音频系统》.pdf NF C97-132-1999 Audio recording Compact disc digital audio system 《音频录制 光盘数字音频系统》.pdf
  • NF C97-133 A2-1997 《NF EN 60856-1993的修改件2》.pdf NF C97-133 A2-1997 《NF EN 60856-1993的修改件2》.pdf
  • 相关搜索

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

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