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

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

1、二级 JAVA机试 77及答案解析(总分:100.00,做题时间:90 分钟)一、B1基本操作题/B(总题数:1,分数:30.00)1.下面程序是关于位运算符的使用。请在程序的每条横线处填写适当的语句,使程序的功能完整。 注意:请勿改动 main()主方法和其他已有的语句内容,仅在横线处填入适当的位运算符。 public class BitOperator public static void main(String args ) int a=9; /二进制数 1001 int b=15; /二进制数 1111 int c=8; /二进制数 1000 int d,e, f,g,h; d=a _

2、 b;/二进制数1001, 也就是十进制数 9 e=a|b;/二进制数 1111, 也就是十进制数 15 f=a _ b;/二进制数 0110, 也就是十进制数 6 g=a2 / /; 94=36 h=c_1;/8/2=4 System. out .println ( “d=“+d); System. out .println ( “e=“+e); System. out .println ( “f=“+f); System. out .println ( “g=“+g); System. out .println ( “h=“+h); (分数:30.00)_二、B2简单应用题/B(总题数:1

3、分数:40.00)2.请完成下列 Java程序。程序的功能是利用迭代法求一个数的平方根(求平方根的迭代公式为:Xn+1=1/2(Xn+a/Xn)。 注意:请勿改动 main()主方法和其他已有的语句内容,仅在下划线处填入适当的语句。 public class PingFangGen public static void main(String args ) System.out.println(Math.sqrt(2.0); static double sqrt(_) double x=1.0; do _ while( Math.abs(x*x-a)/ale-6); return x; (分

4、数:40.00)_三、B3综合应用题/B(总题数:1,分数:30.00)3.下面是一个 Applet程序,其功能是输出已定义好的两个变量 x和 chr。请改正程序中的错误(有下划线的语句),使用序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 程序运行结果如下:(分数:30.00)_二级 JAVA机试 77答案解析(总分:100.00,做题时间:90 分钟)一、B1基本操作题/B(总题数:1,分数:30.00)1.下面程序是关于位运算符的使用。请在程序的每条横线处填写适当的语句,使程序的功能完整。 注意:请勿改动 main()主方法和其他已有的语句内容,仅在横线处填入适当的位运算

5、符。 public class BitOperator public static void main(String args ) int a=9; /二进制数 1001 int b=15; /二进制数 1111 int c=8; /二进制数 1000 int d,e, f,g,h; d=a _ b;/二进制数1001, 也就是十进制数 9 e=a|b;/二进制数 1111, 也就是十进制数 15 f=a _ b;/二进制数 0110, 也就是十进制数 6 g=a2 / /; 94=36 h=c_1;/8/2=4 System. out .println ( “d=“+d); System.

6、out .println ( “e=“+e); System. out .println ( “f=“+f); System. out .println ( “g=“+g); System. out .println ( “h=“+h); (分数:30.00)_正确答案:()解析:h=c1;语句的功能是使变量 c的各二进制位右移 1位,并将结果赋予变量 h。二、B2简单应用题/B(总题数:1,分数:40.00)2.请完成下列 Java程序。程序的功能是利用迭代法求一个数的平方根(求平方根的迭代公式为:Xn+1=1/2(Xn+a/Xn)。 注意:请勿改动 main()主方法和其他已有的语句内容,

7、仅在下划线处填入适当的语句。 public class PingFangGen public static void main(String args ) System.out.println(Math.sqrt(2.0); static double sqrt(_) double x=1.0; do _ while( Math.abs(x*x-a)/ale-6); return x; (分数:40.00)_正确答案:()解析:double a x=(x+a/x); 解析 本题主要考查 do-while循环语句及 Java的基本运算。解答本题需要对 do-while循环语句的用法熟练。do-w

8、hile 循环又称“直到型”循环,它的一般格式为:初始化部分do循环体部分;迭代部分;while(判断部分);说明如下:(1)dowhile 结构首先执行循环体,然后计算终止条件,若结果为 true,则循环执行大括号中的语句或代码块,直到布尔表达式的结果为 false。(2)与 while结构不同的是,do-while 结构的循环至少被执行一次,这是“直到型”循环的特点。在本题中,double a 语句是定义一个 double型变量 a,x=(x+a/x);语句的功能是迭代求出被开平方的变量。三、B3综合应用题/B(总题数:1,分数:30.00)3.下面是一个 Applet程序,其功能是输出已

9、定义好的两个变量 x和 chr。请改正程序中的错误(有下划线的语句),使用序能输出正确的结果。 注意:不改动程序的结构,不得增行或删行。 程序运行结果如下:(分数:30.00)_正确答案:()解析:import javaappletApplet; public class ex34_3 extends Applet public void init() 解析 本题主要考查 Applet小程序的有关知识。解题关键要掌握编写小程序的基本知识。第 1处,应为import javaappletApplet;其功能是导入 Applet类;第 2处,应为 public class ex34_3 extends Applet,其功能是声明继承 Applet类的 ex34_3类;第 3处,应为 pubfic void init(),其功能是重写init()方法。

展开阅读全文
相关资源
猜你喜欢
  • EN 3043-2008 en Aerospace series - Fasteners externally threaded in heat resisting steel FE PA92HT (A286) - Classification 900 MPa 650 Degrees Centigrade manufacturing method optio.pdf EN 3043-2008 en Aerospace series - Fasteners externally threaded in heat resisting steel FE PA92HT (A286) - Classification 900 MPa 650 Degrees Centigrade manufacturing method optio.pdf
  • EN 3044-1998 en Aerospace Series - Installation Holes for Inserts Screw Thread Helical Coil Self-Locking - Design Standard《航空航天系列 螺旋形线圈自锁式螺纹嵌镶件安装孔 设计标准》.pdf EN 3044-1998 en Aerospace Series - Installation Holes for Inserts Screw Thread Helical Coil Self-Locking - Design Standard《航空航天系列 螺旋形线圈自锁式螺纹嵌镶件安装孔 设计标准》.pdf
  • EN 3046-1993 en Aerospace Series - Bearings Airframe Rolling - Rigid Single Row Ball Bearings in Steel Cadmium Plated - Diameter Series 0 and 2 - Reduced Clearance Category - Dimen.pdf EN 3046-1993 en Aerospace Series - Bearings Airframe Rolling - Rigid Single Row Ball Bearings in Steel Cadmium Plated - Diameter Series 0 and 2 - Reduced Clearance Category - Dimen.pdf
  • EN 3047-1993 en Aerospace Series - Bearings Airframe Rolling - Rigid Single Row Ball Bearings in Corrosion Resisting Steel - Diameter Series 0 and 2 - Reduced Clearance Category - .pdf EN 3047-1993 en Aerospace Series - Bearings Airframe Rolling - Rigid Single Row Ball Bearings in Corrosion Resisting Steel - Diameter Series 0 and 2 - Reduced Clearance Category - .pdf
  • EN 3048-2001 en Aerospace series - Bearings spherical plain in corrosion resisting steel with self-lubricating liner - Light series - Elevated load at ambient temperature - Dimensi.pdf EN 3048-2001 en Aerospace series - Bearings spherical plain in corrosion resisting steel with self-lubricating liner - Light series - Elevated load at ambient temperature - Dimensi.pdf
  • EN 3049-1998 en Aerospace Series - O-Rings in Fluorocarbon Rubber (FKM) Low Compression Set - Hardness 80 IRHD《航空航天系列 低压缩变形的氟碳橡胶(FKM)O型环 硬度80IRHD(国际橡胶硬度标度)》.pdf EN 3049-1998 en Aerospace Series - O-Rings in Fluorocarbon Rubber (FKM) Low Compression Set - Hardness 80 IRHD《航空航天系列 低压缩变形的氟碳橡胶(FKM)O型环 硬度80IRHD(国际橡胶硬度标度)》.pdf
  • EN 305-1997 en Heat Exchangers - Definitions of Performance of Heat Exchangers and the General Test Procedures for Establishing Perfomance of All Heat Exchangers《热交换器 热交换器性能的定义和所有热.pdf EN 305-1997 en Heat Exchangers - Definitions of Performance of Heat Exchangers and the General Test Procedures for Establishing Perfomance of All Heat Exchangers《热交换器 热交换器性能的定义和所有热.pdf
  • EN 3050-1998 en Aerospace Series - O-Rings in Fluorocarbon Rubber (FKM) Low Compression Set - Technical Specification《航空航天系列 低压力变形氟碳橡胶(FKM)制O型环 交货技术条件》.pdf EN 3050-1998 en Aerospace Series - O-Rings in Fluorocarbon Rubber (FKM) Low Compression Set - Technical Specification《航空航天系列 低压力变形氟碳橡胶(FKM)制O型环 交货技术条件》.pdf
  • EN 3052-2009 en Aerospace series - Bolts normal hexagonal head close tolerance normal shank short thread in heat and corrosion resisting steel passivated - Classification 1 100 MPa.pdf EN 3052-2009 en Aerospace series - Bolts normal hexagonal head close tolerance normal shank short thread in heat and corrosion resisting steel passivated - Classification 1 100 MPa.pdf
  • 相关搜索

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

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