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

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

1、二级 JAVA 机试-114 及答案解析(总分:100.00,做题时间:90 分钟)一、1基本操作题(总题数:1,分数:33.00)1.return s;(分数:33.00)_二、2简单应用题(总题数:1,分数:33.00)2.下面是一个字符界面的 Java Application 程序,它接受用户输入的一个浮点数,并将它的整数部分和小数部分分别输出。请勿改动原有代码,在下画线处填人适当语句,将程序补充完整。import java.io.*;public class test16_2public static void main(String args) String s;double d;i

2、nt i;boolean b=false;dotrySystem.out.println(“请输入一个浮点数:“);BufferedReader br=new BufferedReader(new lnputStreamReader(System.in);s=br.readLine();i=s.indexOf( );d=_.parseDouble(s);System.out.println(d+“整数部分为:“+_);if(i=-1)System.out.println(d+“小数部分为:0.0“);elseSystem.out.println(d+“小数部分为:“+Double.parseD

3、ouble(s.charAt(0)=-)?“-“:“)+“0.“+s.substring(i+1,s.length();b=false;catch(NumberFormatException nfe) System.out.prinfln(“输入浮点数格式有误。/n“);b=true;catch(IOException ioe)b=false;while(b);(分数:33.00)_三、3综合应用题(总题数:1,分数:34.00)3.下面是一个 Applet 程序,其功能是用一组坐标点绘制一个多边形,并通过沿坐标的垂直方向移动,把它移到窗口的下半部分,然后填充它。请改正程序中的错误(有下画线的

4、语句),使程序能输出正确的结果。注意:不改动程序的结构,不得增行或删行。import java.awt.*;import java.applet.*;/*applet code=“ex16_3.class“width=800 height=400/applet*/public class ex16_3 extends Appletint x=15,50,100,160,120,190;int y=15,100,30,15,80,50 ;public void init()setBackground(Color.lightGray);public void paint(Craphics g)in

5、ty2=new int6;g.setColor(Color.red);Rectangle rect=getBounds();g.drawPolygon(x,y2,6);for(int i=0;i6;i+)Y2i=yi+(rect.height/2);g.fillPolygon(x,y,6);ex16_3.htmlHTMLHEADTITLEex16_3/TITLE/HEADBODYapplet code=ex16_3.class“width=800 height=400/applet/BODY/HTML(分数:34.00)_二级 JAVA 机试-114 答案解析(总分:100.00,做题时间:9

6、0 分钟)一、1基本操作题(总题数:1,分数:33.00)1.return s;(分数:33.00)_正确答案:(n=divsum(n)n%i=0s+=i;)解析:二、2简单应用题(总题数:1,分数:33.00)2.下面是一个字符界面的 Java Application 程序,它接受用户输入的一个浮点数,并将它的整数部分和小数部分分别输出。请勿改动原有代码,在下画线处填人适当语句,将程序补充完整。import java.io.*;public class test16_2public static void main(String args) String s;double d;int i;b

7、oolean b=false;dotrySystem.out.println(“请输入一个浮点数:“);BufferedReader br=new BufferedReader(new lnputStreamReader(System.in);s=br.readLine();i=s.indexOf( );d=_.parseDouble(s);System.out.println(d+“整数部分为:“+_);if(i=-1)System.out.println(d+“小数部分为:0.0“);elseSystem.out.println(d+“小数部分为:“+Double.parseDouble(

8、s.charAt(0)=-)?“-“:“)+“0.“+s.substring(i+1,s.length();b=false;catch(NumberFormatException nfe) System.out.prinfln(“输入浮点数格式有误。/n“);b=true;catch(IOException ioe)b=false;while(b);(分数:33.00)_正确答案:(Double(long)d)解析:三、3综合应用题(总题数:1,分数:34.00)3.下面是一个 Applet 程序,其功能是用一组坐标点绘制一个多边形,并通过沿坐标的垂直方向移动,把它移到窗口的下半部分,然后填充

9、它。请改正程序中的错误(有下画线的语句),使程序能输出正确的结果。注意:不改动程序的结构,不得增行或删行。import java.awt.*;import java.applet.*;/*applet code=“ex16_3.class“width=800 height=400/applet*/public class ex16_3 extends Appletint x=15,50,100,160,120,190;int y=15,100,30,15,80,50 ;public void init()setBackground(Color.lightGray);public void pa

10、int(Craphics g)inty2=new int6;g.setColor(Color.red);Rectangle rect=getBounds();g.drawPolygon(x,y2,6);for(int i=0;i6;i+)Y2i=yi+(rect.height/2);g.fillPolygon(x,y,6);ex16_3.htmlHTMLHEADTITLEex16_3/TITLE/HEADBODYapplet code=ex16_3.class“width=800 height=400/applet/BODY/HTML(分数:34.00)_正确答案:(drawPolygon(x,y,6)y2i+=yi+(rect.height/2)g.fllPolygon(x,y2,6)解析:

展开阅读全文
相关资源
猜你喜欢
  • ITU-R M 1828-2007 Technical and operational requirements for aircraft stations of aeronautical mobile service limited to transmissions of telemetry for flight testing in the bands .pdf ITU-R M 1828-2007 Technical and operational requirements for aircraft stations of aeronautical mobile service limited to transmissions of telemetry for flight testing in the bands .pdf
  • ITU-R M 1829 FRENCH-2007 Method for determining the necessary geographical separation distances in the 5 GHz band between the international standard microwave landing system (MLS) av.pdf ITU-R M 1829 FRENCH-2007 Method for determining the necessary geographical separation distances in the 5 GHz band between the international standard microwave landing system (MLS) av.pdf
  • ITU-R M 1829 SPANISH-2007 Method for determining the necessary geographical separation distances in the 5 GHz band between the international standard microwave landing system (MLS)na.pdf ITU-R M 1829 SPANISH-2007 Method for determining the necessary geographical separation distances in the 5 GHz band between the international standard microwave landing system (MLS)na.pdf
  • ITU-R M 1829-2007 Method for determining the necessary geographical separation distances in the 5 GHz band between the international standard microwave landing system (MLS) stationon.pdf ITU-R M 1829-2007 Method for determining the necessary geographical separation distances in the 5 GHz band between the international standard microwave landing system (MLS) stationon.pdf
  • ITU-R M 1830 FRENCH-2007 Technical characteristics and protection criteria of aeronautical radionavigation service systems in the 645-862 MHz frequency band《在645-862 MHz频段的航空无线电导航业.pdf ITU-R M 1830 FRENCH-2007 Technical characteristics and protection criteria of aeronautical radionavigation service systems in the 645-862 MHz frequency band《在645-862 MHz频段的航空无线电导航业.pdf
  • ITU-R M 1830 SPANISH-2007 Technical characteristics and protection criteria of aeronautical radionavigation service systems in the 645-862 MHz frequency band《在645-862 MHz频段的航空无线电导航.pdf ITU-R M 1830 SPANISH-2007 Technical characteristics and protection criteria of aeronautical radionavigation service systems in the 645-862 MHz frequency band《在645-862 MHz频段的航空无线电导航.pdf
  • ITU-R M 1830-2007 Technical characteristics and protection criteria of aeronautical radionavigation service systems in the 645-862 MHz frequency band《在645-862 MHz频段的技术特性和航空无线电导航业务系.pdf ITU-R M 1830-2007 Technical characteristics and protection criteria of aeronautical radionavigation service systems in the 645-862 MHz frequency band《在645-862 MHz频段的技术特性和航空无线电导航业务系.pdf
  • ITU-R M 1831-1-2015 A coordination methodology for radionavigation-satellite service inter-system interference estimation《卫星无线电导航系统间干扰估计的协调方法》.pdf ITU-R M 1831-1-2015 A coordination methodology for radionavigation-satellite service inter-system interference estimation《卫星无线电导航系统间干扰估计的协调方法》.pdf
  • ITU-R M 1841-1-2013 Compatibility between FM sound-broadcasting systems in the frequency band of about 87-108 MHz and the aeronautical ground-based augmentation system in the frequ.pdf ITU-R M 1841-1-2013 Compatibility between FM sound-broadcasting systems in the frequency band of about 87-108 MHz and the aeronautical ground-based augmentation system in the frequ.pdf
  • 相关搜索

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

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