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

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

1、二级 JAVA 机试-93 及答案解析(总分:100.00,做题时间:90 分钟)一、1基本操作题(总题数:1,分数:33.00)1.下列程序中,要求建立一个包含一个方法的类,这个方法实现数组的拷贝,要求首先用直接初始化原始数组,然后将原始数组中的数据拷贝到目的数组,并分别输出原始数组和目的数组。要求数组类型为String 类型,大小为 4,采用动态分配的方式对数组进行初始化。请将程序补充完整。程序运行结果如下:原始的:小龙小张小李小陈复制后的:小龙小张小李小陈public class ex5_1 public static void main(Stringargs) ex5_1 obj5_1

2、:new ex5_1();obj5_1._;public void method5_1()int i=0;String strMember = new String4;String strTemp = new String4;strMember0 = “小龙“ ;strMember1 = “小张“ ;strMember2 = “小李“ ;strMember3 = “小陈“ ;for(i=0; i4; i+)_;System.out.println(“原始的;“);for(i=0; i4; i+)System.out.println(_);System.out.println(“复制后的:“);

3、for(i=0; i4; i+)System.out.println (strTempi);(分数:33.00)_二、2简单应用题(总题数:1,分数:33.00)2.System.out.println(vName.get(j);(分数:33.00)_三、3综合应用题(总题数:1,分数:34.00)3.下面是一个 Applet 程序,其功能是通过一个按钮控制一个窗口的创建,显示与隐藏,并且以按钮文字作为提示,可以随着窗口的状态改变,即如果窗口出现,则按钮文字为“Hide myFrm”,提示用户点击按钮,则隐藏窗口,反之亦然。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。注意:不

4、改动程序的结构,不得增行或删行。程序运行结果如下:(分数:34.00)_二级 JAVA 机试-93 答案解析(总分:100.00,做题时间:90 分钟)一、1基本操作题(总题数:1,分数:33.00)1.下列程序中,要求建立一个包含一个方法的类,这个方法实现数组的拷贝,要求首先用直接初始化原始数组,然后将原始数组中的数据拷贝到目的数组,并分别输出原始数组和目的数组。要求数组类型为String 类型,大小为 4,采用动态分配的方式对数组进行初始化。请将程序补充完整。程序运行结果如下:原始的:小龙小张小李小陈复制后的:小龙小张小李小陈public class ex5_1 public static

5、 void main(Stringargs) ex5_1 obj5_1:new ex5_1();obj5_1._;public void method5_1()int i=0;String strMember = new String4;String strTemp = new String4;strMember0 = “小龙“ ;strMember1 = “小张“ ;strMember2 = “小李“ ;strMember3 = “小陈“ ;for(i=0; i4; i+)_;System.out.println(“原始的;“);for(i=0; i4; i+)System.out.prin

6、tln(_);System.out.println(“复制后的:“);for(i=0; i4; i+)System.out.println (strTempi);(分数:33.00)_正确答案:(method5_1()strTempi = strMemberistrMemberi)解析:解析本题主要考查数组和字符串的基本操作,for 循环语句以及对象调用方法的基本思想。解题关键是熟练掌握一维数组和字符串的基本操作,掌握如何确定 for 循环的上下界,会用面向对象的基本思想。本题中,第 1 个空,用对象 obj5_1 调用方法 method5_1():第 2 个空,实现数组的拷贝,将原始的数组拷

7、贝到目的数组;第 3 个空,输出原始数组中的每一个数据项。二、2简单应用题(总题数:1,分数:33.00)2.System.out.println(vName.get(j);(分数:33.00)_正确答案:(vName.add(strNamei)Collections.sort(vName)解析:解析本题主要考查汇集(Collections)接口和数组的操作。解题关键是熟悉数组的直接初始化方法,掌握Vector 类和 Collections 类的基本方法。本题中,第一空,将 strName 数组中的每一个 String 对象添加到 Vector 类的 vName 对象中,调用方法 add 实现

8、这一过程;第二空,利用 Collections 的 sort 方法来对vName 对象中的字符串进行自然排序。三、3综合应用题(总题数:1,分数:34.00)3.下面是一个 Applet 程序,其功能是通过一个按钮控制一个窗口的创建,显示与隐藏,并且以按钮文字作为提示,可以随着窗口的状态改变,即如果窗口出现,则按钮文字为“Hide myFrm”,提示用户点击按钮,则隐藏窗口,反之亦然。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。注意:不改动程序的结构,不得增行或删行。程序运行结果如下:(分数:34.00)_正确答案:(frm ! = nullfrm.hide()frm.sho

9、w()解析:解析本题主要考查 Applet 窗口及 Applet 程序的执行过程,和图形用户界面程序的设计。解题关键是熟悉Applet 窗口程序设计及其执行过程,这里要求加入一个 Button 构件;同时需要熟悉图形用户界面的设计,这里要求通过 Applet 中的 Button 构件控制一个 Frame 窗口的显示与隐藏,要熟悉如何建立一个新窗口,如何设置窗口的标题,如何利用 Component 类的方法将窗口关闭。本题中,要正确解答,需要明确程序的控制流程:首先判断用户是否按下按钮,其次判断当前窗口对象是否存在,如果窗口不存在则定义一个窗口,反之将窗口隐藏,并同时修改按钮文字作为提示,要明白提示作用是如果存在则提示关掉,如果不存在则提示显示。第一处,判断条件应该是 frm!=null,作用是判断当前窗口对象是否存在,存在的情况下才应该隐藏;第二处,这部分语句是用来隐藏窗口的,所以,应该是 frm.hide();同理第三处错误应该是 frm.show()。

展开阅读全文
相关资源
猜你喜欢
  • GOST R 8 815-2013 State system for ensuring the uniformity of measurements Secondary standarts of the units of length velocity and acceleration by vibration of a solid body Techniq.pdf GOST R 8 815-2013 State system for ensuring the uniformity of measurements Secondary standarts of the units of length velocity and acceleration by vibration of a solid body Techniq.pdf
  • GOST R 8 816-2013 State system for ensuring the uniformity of measurements Natural gas Volumetric heat (energy) of combustion Method for measurement using the bomb calorimeter《确保测量.pdf GOST R 8 816-2013 State system for ensuring the uniformity of measurements Natural gas Volumetric heat (energy) of combustion Method for measurement using the bomb calorimeter《确保测量.pdf
  • GOST R 8 817-2013 State system for ensuring the uniformity of measurements State verification schedule for measuring instruments of standard lightning and switching impulse electri测.pdf GOST R 8 817-2013 State system for ensuring the uniformity of measurements State verification schedule for measuring instruments of standard lightning and switching impulse electri测.pdf
  • GOST R 8 818-2013 State system for ensuring the uniformity of measurements Virtual measuring instruments and virtual measuring systems General principles《确保测量一致性的国家系统 虚拟测量仪器和虚拟测量系统.pdf GOST R 8 818-2013 State system for ensuring the uniformity of measurements Virtual measuring instruments and virtual measuring systems General principles《确保测量一致性的国家系统 虚拟测量仪器和虚拟测量系统.pdf
  • GOST R 8 819-2013 State system for ensuring the uniformity of measurements State verification schedule for measuring tools for determination component composition of gas condensate.pdf GOST R 8 819-2013 State system for ensuring the uniformity of measurements State verification schedule for measuring tools for determination component composition of gas condensate.pdf
  • GOST R 8 820-2013 State system for ensuring the uniformity of measurements Metrological assurance General《确保测量一致性的国家系统 计量保证 总则》.pdf GOST R 8 820-2013 State system for ensuring the uniformity of measurements Metrological assurance General《确保测量一致性的国家系统 计量保证 总则》.pdf
  • GOST R 8 821-2013 State system for ensuring the uniformity of measurements Instruments for measurement of pulsation coefficient Verification procedure《确保测量一致性的国家系统 脉动系数测量仪器 验证程序》.pdf GOST R 8 821-2013 State system for ensuring the uniformity of measurements Instruments for measurement of pulsation coefficient Verification procedure《确保测量一致性的国家系统 脉动系数测量仪器 验证程序》.pdf
  • GOST R 8 822-2013 State system for ensuring the uniformity of measurements The determination of the corrective factor on get fat capacity carrying oil tank court at measurement of ion《.pdf GOST R 8 822-2013 State system for ensuring the uniformity of measurements The determination of the corrective factor on get fat capacity carrying oil tank court at measurement of ion《.pdf
  • GOST R 8 823-2013 State system for ensuring the uniformity of measurements Meters for hot water General metrological and technical requirements《确保测量一致性的国家系统 热水表 通用计量和技术要求》.pdf GOST R 8 823-2013 State system for ensuring the uniformity of measurements Meters for hot water General metrological and technical requirements《确保测量一致性的国家系统 热水表 通用计量和技术要求》.pdf
  • 相关搜索

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

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