【计算机类职业资格】二级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)解析:

展开阅读全文
相关资源
猜你喜欢
  • DIN ETS 300297-1995 Integrated Services Digital Network (ISDN) - Access digital section for ISDN basic access English version ETS 300297 1995《综合服务数字网(ISDN) ISDN基础连接用数字通道截面》.pdf DIN ETS 300297-1995 Integrated Services Digital Network (ISDN) - Access digital section for ISDN basic access English version ETS 300297 1995《综合服务数字网(ISDN) ISDN基础连接用数字通道截面》.pdf
  • DIN ETS 300298-1-2000 Broadband Integrated Service Digital Network (B-ISDN) - Asynchronous Transfer Mode (ATM) - Part 1 B-ISDN ATM functional characteristics [ITU-T Recommendation .pdf DIN ETS 300298-1-2000 Broadband Integrated Service Digital Network (B-ISDN) - Asynchronous Transfer Mode (ATM) - Part 1 B-ISDN ATM functional characteristics [ITU-T Recommendation .pdf
  • DIN ETS 300298-2-2000 Broadband Integrated Service Digital Network (B-ISDN) - Asynchronous Transfer Mode (ATM) - Part 2 B-ISDN ATM layer specification [ITU-T Recommendation I 361 (.pdf DIN ETS 300298-2-2000 Broadband Integrated Service Digital Network (B-ISDN) - Asynchronous Transfer Mode (ATM) - Part 2 B-ISDN ATM layer specification [ITU-T Recommendation I 361 (.pdf
  • DIN ETS 300298-3-2000 Broadband Integrated Service Digital Network (B-ISDN) - Asynchronous Transfer Mode (ATM) - Part 3 Protocol Implementation Conformance Statement (PICS) proform.pdf DIN ETS 300298-3-2000 Broadband Integrated Service Digital Network (B-ISDN) - Asynchronous Transfer Mode (ATM) - Part 3 Protocol Implementation Conformance Statement (PICS) proform.pdf
  • DIN ETS 300300-1998 Broadband Integrated Services Digital Network (B-ISDN) - Synchronous Digital Hierarchy (SDH) based user network access - Physical Layer User Network Interface (o.pdf DIN ETS 300300-1998 Broadband Integrated Services Digital Network (B-ISDN) - Synchronous Digital Hierarchy (SDH) based user network access - Physical Layer User Network Interface (o.pdf
  • DIN ETS 300303 Berichtigung 2-1996 Corrigendum to DIN ETS 300303 1995-01 (ETS 300303 1994 Corrigendum 1996)《DIN ETS 300303 1995-01(ETS 300303 1994 勘误表 1996)技术勘误》.pdf DIN ETS 300303 Berichtigung 2-1996 Corrigendum to DIN ETS 300303 1995-01 (ETS 300303 1994 Corrigendum 1996)《DIN ETS 300303 1995-01(ETS 300303 1994 勘误表 1996)技术勘误》.pdf
  • DIN ETS 300303-1995 Integrated Services Digital Network (ISDN) - ISDN-Global System for Mobile Communications (GSM) - Public Land Mobile Network (PLMN) signalling interface English.pdf DIN ETS 300303-1995 Integrated Services Digital Network (ISDN) - ISDN-Global System for Mobile Communications (GSM) - Public Land Mobile Network (PLMN) signalling interface English.pdf
  • DIN ETS 300304-1997 Transmission and Multiplexing (TM) - Synchronous Digital Hierarchy (SDH) - SDH information model for the Network Element (NE) view English version ETS 300304 19.pdf DIN ETS 300304-1997 Transmission and Multiplexing (TM) - Synchronous Digital Hierarchy (SDH) - SDH information model for the Network Element (NE) view English version ETS 300304 19.pdf
  • DIN ETS 300323-1 A1-1995 Radio Equipment and Systems (RES) - Digital European Cordless Telecommunications (DECT) Public Access Profile (PAP) test specification - Part 1 Overview En.pdf DIN ETS 300323-1 A1-1995 Radio Equipment and Systems (RES) - Digital European Cordless Telecommunications (DECT) Public Access Profile (PAP) test specification - Part 1 Overview En.pdf
  • 相关搜索

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

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