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

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

1、二级 JAVA 机试-163 及答案解析(总分:100.00,做题时间:90 分钟)一、1基本操作题(总题数:1,分数:33.00)1.下列 Application 程序中,指定 v 为 32 位整数类型,求出 v 的绝对值并输出,请将程序补充完整。class test19_1 public static void main(String args) _v=-100;char ch=_Math._(v); Systemoutprintln(“ch=“+ch);(分数:33.00)填空项 1:_二、2简单应用题(总题数:1,分数:33.00)2.下列 Application 程序输入一个整数,求

2、出它的所有因子,请根据注释,将程序补充完整。public class test19_2 public static void main(String args)throws IOException int n;/下面 7 行语句的作用是从键盘输入 n 的值InputStreamReader ir; BufferedReader in;ir=new lnputStreamReader(System.in);in=new BufferedReader(ir);Systemoutprintln(“Input n is:“);String s=in._;/读取 1 行字符n=Integer.parse

3、Int(s);/下面求 n 的所有因子_(int i=1;i=n;i+) if(n%i!=0)_;/跳过打印语句回到循环起始Systemoutprint(i+”);Systemoutprint(“/n”);(分数:33.00)_三、3综合应用题(总题数:1,分数:34.00)3.下面是一个 Applet 程序,其功能是进行整数加法运算,要求有 3 个文本区域,2 个作为输入, 1 个作为输出,并且由异常处理来判断输入的数字是否为整型,如果是则进行运算,否则抛出异常并显示在第 3个文本区域中。请改正程序中的错误(有下画线的语句),使程序能输出正确的结果。注意:不改动程序的结构,不得增行或删行。i

4、mport javaawt*;impoat javaawtevent*;impoat javaappletApplet; /*applet code=“exl7_3class“,width=800 heiSht=400/applet*/ public class exl7_3 extends Applet implements ActionListener TextField tfl=new TextField(5);TextField tf2=new TextField(5);TextField tf3=newTextField(5);Label 11=new Label(“+“); Lab

5、el l2=new Label(“=“);Button btn=new Button(“add“);public void init( )add(11);add(tf1);add(tf2);add(12);add(tf3);add(btn);btnaddActionListener(this);public void actionPerformed(ActionEvent ae) try int a=IntegerparseInt(tf1getText();int b=IntegerparseInt(tf2getText(); int x=a+b;tf2setText(IntegertoStr

6、ing(x);catch(NumberFormatException nfe) tf3setText(“error!“);ex19_3htmlHTMLHEADTITLEexl9_3/TITLE/HEADBODYapplet code=“ex19_3.clasS“width=800 height=400/applet/BODY/HTML(分数:34.00)_二级 JAVA 机试-163 答案解析(总分:100.00,做题时间:90 分钟)一、1基本操作题(总题数:1,分数:33.00)1.下列 Application 程序中,指定 v 为 32 位整数类型,求出 v 的绝对值并输出,请将程序补充

7、完整。class test19_1 public static void main(String args) _v=-100;char ch=_Math._(v); Systemoutprintln(“ch=“+ch);(分数:33.00)填空项 1:_ (正确答案:int (char) abs)解析:二、2简单应用题(总题数:1,分数:33.00)2.下列 Application 程序输入一个整数,求出它的所有因子,请根据注释,将程序补充完整。public class test19_2 public static void main(String args)throws IOExceptio

8、n int n;/下面 7 行语句的作用是从键盘输入 n 的值InputStreamReader ir; BufferedReader in;ir=new lnputStreamReader(System.in);in=new BufferedReader(ir);Systemoutprintln(“Input n is:“);String s=in._;/读取 1 行字符n=Integer.parseInt(s);/下面求 n 的所有因子_(int i=1;i=n;i+) if(n%i!=0)_;/跳过打印语句回到循环起始Systemoutprint(i+”);Systemoutprint(

9、/n”);(分数:33.00)_正确答案:(readLine( ) for continue)解析:三、3综合应用题(总题数:1,分数:34.00)3.下面是一个 Applet 程序,其功能是进行整数加法运算,要求有 3 个文本区域,2 个作为输入, 1 个作为输出,并且由异常处理来判断输入的数字是否为整型,如果是则进行运算,否则抛出异常并显示在第 3个文本区域中。请改正程序中的错误(有下画线的语句),使程序能输出正确的结果。注意:不改动程序的结构,不得增行或删行。import javaawt*;impoat javaawtevent*;impoat javaappletApplet; /*

10、applet code=“exl7_3class“,width=800 heiSht=400/applet*/ public class exl7_3 extends Applet implements ActionListener TextField tfl=new TextField(5);TextField tf2=new TextField(5);TextField tf3=newTextField(5);Label 11=new Label(“+“); Label l2=new Label(“=“);Button btn=new Button(“add“);public void i

11、nit( )add(11);add(tf1);add(tf2);add(12);add(tf3);add(btn);btnaddActionListener(this);public void actionPerformed(ActionEvent ae) try int a=IntegerparseInt(tf1getText();int b=IntegerparseInt(tf2getText(); int x=a+b;tf2setText(IntegertoString(x);catch(NumberFormatException nfe) tf3setText(“error!“);ex19_3htmlHTMLHEADTITLEexl9_3/TITLE/HEADBODYapplet code=“ex19_3.clasS“width=800 height=400/applet/BODY/HTML(分数:34.00)_正确答案:(add(tf1)add(11)tf3setText(IntegertoString(x)解析:

展开阅读全文
相关资源
猜你喜欢
  • CEPT T R 01-02 E-1988 Monitoring of Emissions Where Space-Service Stations Are Involved (Interlaken 1968 Revised at the Hague 1971)《涉及空间业务站的发射量监控 因特拉肯1968年 1971年在海牙修订》.pdf CEPT T R 01-02 E-1988 Monitoring of Emissions Where Space-Service Stations Are Involved (Interlaken 1968 Revised at the Hague 1971)《涉及空间业务站的发射量监控 因特拉肯1968年 1971年在海牙修订》.pdf
  • CEPT T R 01-03 E-1980 Monitoring of Satellite Transmissions《卫星传输监控》.pdf CEPT T R 01-03 E-1980 Monitoring of Satellite Transmissions《卫星传输监控》.pdf
  • CEPT T R 01-03 E-1988 Monitoring of Satellite Transmissions (Brussels 1980)《卫星传输监控 布鲁塞尔1980年》.pdf CEPT T R 01-03 E-1988 Monitoring of Satellite Transmissions (Brussels 1980)《卫星传输监控 布鲁塞尔1980年》.pdf
  • CEPT T R 01-04 E-1992 Use of Low Power Devices (LPD) Using Integral Antennas and Operating in Harmonized Frequency《使用一体化天线和在统一频率中运行的低功率设备(LPD)的使用》.pdf CEPT T R 01-04 E-1992 Use of Low Power Devices (LPD) Using Integral Antennas and Operating in Harmonized Frequency《使用一体化天线和在统一频率中运行的低功率设备(LPD)的使用》.pdf
  • CEPT T R 01-04 E-1993 Use of Low Power Devices (LPD) Using Integral Antennas and Operating in Harmonised Frequency Bands (Oslo 1991 Revised in Madrid 1992)《使用一体化天线和在统一频带中运行的低功率设备(L.pdf CEPT T R 01-04 E-1993 Use of Low Power Devices (LPD) Using Integral Antennas and Operating in Harmonised Frequency Bands (Oslo 1991 Revised in Madrid 1992)《使用一体化天线和在统一频带中运行的低功率设备(L.pdf
  • CEPT T R 01-05 E-1993 Transposition of National Standards to Enable Introduction of European Standards (Madrid 1992)《国家标准置换以引入欧洲标准 马德里1992年》.pdf CEPT T R 01-05 E-1993 Transposition of National Standards to Enable Introduction of European Standards (Madrid 1992)《国家标准置换以引入欧洲标准 马德里1992年》.pdf
  • CEPT T R 02-01 E-1986 Planning and Co-Ordination of Land Mobile and Other Services Operating in the Band 47-68 HMz《47-68 MHz频段运行地面移动和其他业务的规划和协调》.pdf CEPT T R 02-01 E-1986 Planning and Co-Ordination of Land Mobile and Other Services Operating in the Band 47-68 HMz《47-68 MHz频段运行地面移动和其他业务的规划和协调》.pdf
  • CEPT T R 02-01 E-1988 Planning and Coordination of Land Mobile (and Other) Services Operating in the Band 47-68 MHz《47-68 MHz频段运行地面移动(和其他)业务的规划和协调 欧登塞1986年》.pdf CEPT T R 02-01 E-1988 Planning and Coordination of Land Mobile (and Other) Services Operating in the Band 47-68 MHz《47-68 MHz频段运行地面移动(和其他)业务的规划和协调 欧登塞1986年》.pdf
  • CEPT T R 02-02 E-1993 Harmonised Frequency Band for the Emergency Services《应急业务统一无线电频道安排》.pdf CEPT T R 02-02 E-1993 Harmonised Frequency Band for the Emergency Services《应急业务统一无线电频道安排》.pdf
  • 相关搜索

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

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