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

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

1、二级 JAVA 机试-76 及答案解析(总分:100.00,做题时间:90 分钟)一、1基本操作题(总题数:1,分数:33.00)1.System.out.println(ai+ “ );(分数:33.00)_二、2简单应用题(总题数:1,分数:33.00)2.请完成下列 Java 程序:对大写的 26 个英文字母加密,从键盘输入一个大写字母串,输出这个串加密后的结果。加密操作是将字母变换成倒序的大写字母,如 A-Z,B-Y。注意:请勿改动 main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。程序运行结果如下:输入一个大写字母串:ADFSDFFE加密后的大写字母串:ZWUHWUU

2、Vimport java.io.*;public class ex12_2public static void main (String args)char ch = A;String str;System. out .print ( “输入一个大写字母串: “);tryBufferedReader in = new BufferedReader(new InputStreamReader(System.in);str= in.readLine();System. out .print ( “加密后的大写字母串:“);for(int i=0;istr.length();i+)_;_;Syste

3、m.out.print(ch);catch(IOException e)trySystem.in.read();catch(IOException e) ;(分数:33.00)_三、3综合应用题(总题数:1,分数:34.00)3.下面是一个 Applet 程序,其功能是显示有闪烁特效的从左向右的滚动文字。要求定义 6 种颜色:RED,GREEN,ORANGE, GRAY,YELLOW,BLUE,让文字在滚动过程中根据文字的位置循环选定种颜色,并快速切换,达到一边移动一边闪烁的效果,同时要求通过 htm1 文件传递所显示的文字和延迟时间的参数,Applet 程序能够根据参数实现显示功能。请改正程

4、序中的错误(有下划线的语句),使程序能输山正确的结果。注意:不改动程序的结构,不得增行或删行。程序运行结果如下:(分数:34.00)_二级 JAVA 机试-76 答案解析(总分:100.00,做题时间:90 分钟)一、1基本操作题(总题数:1,分数:33.00)1.System.out.println(ai+ “ );(分数:33.00)_正确答案:(isize-1;jsize;ai=aj;)解析:解析本题考查 for 循环语句。解答本题的关键是掌握选择排序算法和 Java 语言数组的基本用法。在本题中,第一个 for(i=0;size-1;i+)循环语句是用来从数组 a 中选出最小值,(其中

5、 isize-1;语句是判断部分),将它放在前面第 0 位置;第二个 for(j=i+1;size;j+)循环语勺是用来在数组 a 剩下的数中选择最小值,(其中 jsize;语句是判断部分)将它放在前面第 1 位置,依此类推。最后 ai=aj;语句是用来交换数组中前后相邻元素的值。二、2简单应用题(总题数:1,分数:33.00)2.请完成下列 Java 程序:对大写的 26 个英文字母加密,从键盘输入一个大写字母串,输出这个串加密后的结果。加密操作是将字母变换成倒序的大写字母,如 A-Z,B-Y。注意:请勿改动 main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。程序运行结果如下

6、输入一个大写字母串:ADFSDFFE加密后的大写字母串:ZWUHWUUVimport java.io.*;public class ex12_2public static void main (String args)char ch = A;String str;System. out .print ( “输入一个大写字母串: “);tryBufferedReader in = new BufferedReader(new InputStreamReader(System.in);str= in.readLine();System. out .print ( “加密后的大写字母串:“);fo

7、r(int i=0;istr.length();i+)_;_;System.out.print(ch);catch(IOException e)trySystem.in.read();catch(IOException e) ;(分数:33.00)_正确答案:(ch=strcharAt(i)ch=(char)(Z -ch+A)解析:解析本题主要考查字符串的操作和 I/O 操作的简单应用。解题关键是,熟悉字符串的基本操作,会将字符作相应的转换,熟悉字符串的定位方法 charAt()以及基本的 I/O 操作。本题中,第 1 个空,定位 str 对象中的字符,调用 str 对象的 cheat()方法

8、定位第 i 个字符并将该字符写给 ch 变量;第 2 个空,加密算法的实现,Z-ch 表示字符 ch 在字符表中和字符Z之间相隔多少字符,再加上字符A就得到了倒序的字符在字符表中的位置,然后进行类型转换,就得到了倒序的字符。三、3综合应用题(总题数:1,分数:34.00)3.下面是一个 Applet 程序,其功能是显示有闪烁特效的从左向右的滚动文字。要求定义 6 种颜色:RED,GREEN,ORANGE, GRAY,YELLOW,BLUE,让文字在滚动过程中根据文字的位置循环选定种颜色,并快速切换,达到一边移动一边闪烁的效果,同时要求通过 htm1 文件传递所显示的文字和延迟时间的参数,App

9、let 程序能够根据参数实现显示功能。请改正程序中的错误(有下划线的语句),使程序能输山正确的结果。注意:不改动程序的结构,不得增行或删行。程序运行结果如下:(分数:34.00)_正确答案:(return (s != null) ? S : S2nX=getSize()width-nX= 0)解析:解析本题主要考查 Applet 窗口中使用多线程显示动态文字,Applet 与 htm1 文件的信息交换以及方法重载的编程思想。解题关键是熟练掌握在 Applet 窗口中控制文字显示和改变文字的颜色大小等基本操作,熟悉Applet 下的多线程编程思想,熟练应用方法重载解决实际应用,以及掌握 Applet 和 htm1 文件之间通过传递参数来进行信息交互的方法。本题中,第一处,由于 s 是 String 类的对象,因此不需要做类型转换;第二处,nX 是代表了文字的横坐标位置,应该是 getSize()width:第三处,只判断了文字横坐标是否溢出屏幕,但是没有对坐标值改变,文字不会移动,因此需要将 nX 改为-nX。

展开阅读全文
相关资源
猜你喜欢
  • DIN EN 301842-4-2015 VHF air-ground Digital Link (VDL) Mode 4 radio equipment - Technical characteristics and methods of measurement for ground-based equipment - Part 4 Point-to-po.pdf DIN EN 301842-4-2015 VHF air-ground Digital Link (VDL) Mode 4 radio equipment - Technical characteristics and methods of measurement for ground-based equipment - Part 4 Point-to-po.pdf
  • DIN EN 301842-5-2017 VHF air-ground Digital Link (VDL) Mode 4 radio equipment - Technical characteristics and methods of measurement for ground-based equipment - Part 5 Harmonised .pdf DIN EN 301842-5-2017 VHF air-ground Digital Link (VDL) Mode 4 radio equipment - Technical characteristics and methods of measurement for ground-based equipment - Part 5 Harmonised .pdf
  • DIN EN 301843-4-2016 ElectroMagnetic Compatibility (EMC) standard for marine radio equipment and services - Harmonised Standard covering the essential requirements of article 3 1b .pdf DIN EN 301843-4-2016 ElectroMagnetic Compatibility (EMC) standard for marine radio equipment and services - Harmonised Standard covering the essential requirements of article 3 1b .pdf
  • DIN EN 301843-6-2016 ElectroMagnetic Compatibility (EMC) standard for marine radio equipment and services - Harmonised Standard covering the essential requirements of article 3 1b .pdf DIN EN 301843-6-2016 ElectroMagnetic Compatibility (EMC) standard for marine radio equipment and services - Harmonised Standard covering the essential requirements of article 3 1b .pdf
  • DIN EN 301846-2001 Private Integrated Services Network (PISN) - Profile Standard for the Use of PSS1 (QSIG) in Air Traffic Services Networks (Endorsement of the English version EN .pdf DIN EN 301846-2001 Private Integrated Services Network (PISN) - Profile Standard for the Use of PSS1 (QSIG) in Air Traffic Services Networks (Endorsement of the English version EN .pdf
  • DIN EN 301848-1-2001 Integrated Service Digital Network (ISDN) Signalling System No 7 (SS7) Bearer Independent Call Control (BICC) - Signalling procedures in an ATM IP  backbone ne.pdf DIN EN 301848-1-2001 Integrated Service Digital Network (ISDN) Signalling System No 7 (SS7) Bearer Independent Call Control (BICC) - Signalling procedures in an ATM IP backbone ne.pdf
  • DIN EN 301850-1-2002 Integrated Services Digital Network (ISDN) - Signalling System No 7 (SS7) ISDN User Part (ISUP) Application transport mechanism Support of the generic addressi.pdf DIN EN 301850-1-2002 Integrated Services Digital Network (ISDN) - Signalling System No 7 (SS7) ISDN User Part (ISUP) Application transport mechanism Support of the generic addressi.pdf
  • DIN EN 301893-2017 5 GHz RLAN - Harmonised Standard covering the essential requirements of article 3 2 of Directive 2014 53 EU (Endorsement of the English version EN 301 893 V2 1 1.pdf DIN EN 301893-2017 5 GHz RLAN - Harmonised Standard covering the essential requirements of article 3 2 of Directive 2014 53 EU (Endorsement of the English version EN 301 893 V2 1 1.pdf
  • DIN EN 301905-2003 Corporate telecommunication Networks (CN) - Signalling interworking between QSIG and H 323 - Generic functional protocol for the support of supplementary servicef.pdf DIN EN 301905-2003 Corporate telecommunication Networks (CN) - Signalling interworking between QSIG and H 323 - Generic functional protocol for the support of supplementary servicef.pdf
  • 相关搜索
    资源标签

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

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