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

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

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

2、 1001, 也就是十进制数 9e=a|b;/二进制数 1111, 也就是十进制数 15f=a _ b;/二进制数 0110, 也就是十进制数 6g=a2 / /; 94=36h=c_1;/8/2=4System. 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)_二、2简单应用题(总题数:1,分数:40.00)2.return x

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

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

5、 “e=“+e);System. out .println ( “f=“+f);System. out .println ( “g=“+g);System. out .println ( “h=“+h);(分数:30.00)_正确答案:(h=c1;语句的功能是使变量 c 的各二进制位右移 1 位,并将结果赋予变量 h。二、2简单应用题(总题数:1,分数:40.00)2.return x;(分数:40.00)_正确答案:(double ax=(x+a/x);)解析:解析本题主要考查 do-while 循环语句及 Java 的基本运算。解答本题需要对 do-while 循环语句的用法熟练。do-

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

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

展开阅读全文
相关资源
猜你喜欢
  • EN ISO 16000-9-2006 en Indoor air - Part 9 Determination of the emission of volatile organic compounds from building products and furnishing - Emission test chamber method (Incorpo.pdf EN ISO 16000-9-2006 en Indoor air - Part 9 Determination of the emission of volatile organic compounds from building products and furnishing - Emission test chamber method (Incorpo.pdf
  • EN ISO 16001-2017 en Earth-moving machinery - Object detection systems and visibility aids - Performance requirements and tests.pdf EN ISO 16001-2017 en Earth-moving machinery - Object detection systems and visibility aids - Performance requirements and tests.pdf
  • EN ISO 16014-5-2012 en Plastics - Determination of average molecular mass and molecular mass distribution of polymers using size-exclusion chromatography - Part 5 Method using ligh.pdf EN ISO 16014-5-2012 en Plastics - Determination of average molecular mass and molecular mass distribution of polymers using size-exclusion chromatography - Part 5 Method using ligh.pdf
  • EN ISO 16017-1-2000 en Indoor Ambient and Workplace Air - Sampling and Analysis of Volatile Organic Compounds by Sorbent Tube Thermal Desorption Capillary Gas Chromatography - Part.pdf EN ISO 16017-1-2000 en Indoor Ambient and Workplace Air - Sampling and Analysis of Volatile Organic Compounds by Sorbent Tube Thermal Desorption Capillary Gas Chromatography - Part.pdf
  • EN ISO 16017-2-2003 en Indoor ambient and workplace air - Sampling and analysis of volatile organic compounds by sorbent tube thermal desorption capillary gas chromatography - Part.pdf EN ISO 16017-2-2003 en Indoor ambient and workplace air - Sampling and analysis of volatile organic compounds by sorbent tube thermal desorption capillary gas chromatography - Part.pdf
  • EN ISO 16021-2000 en Urine-Absorbing Aids - Basic Principles for Evaluation of Single-Use Adult-Incontinence-Absorbing Aids from the Perspective of Users and Caregivers《吸尿器材 从使用者和护.pdf EN ISO 16021-2000 en Urine-Absorbing Aids - Basic Principles for Evaluation of Single-Use Adult-Incontinence-Absorbing Aids from the Perspective of Users and Caregivers《吸尿器材 从使用者和护.pdf
  • EN ISO 16032-2004 en Acoustics - Measurement of sound pressure level from service equipment in buildings - Engineering method《声学 建筑物服务设备的声压级测量 工程法 ISO 16032-2004》.pdf EN ISO 16032-2004 en Acoustics - Measurement of sound pressure level from service equipment in buildings - Engineering method《声学 建筑物服务设备的声压级测量 工程法 ISO 16032-2004》.pdf
  • EN ISO 16035-2005 en Animal and vegetable fats and oils Determination of low-boiling halogenated hydrocarbons in edible oils《动物和植物脂肪和油 食用油中低沸点卤代烃的测定 (ISO 16035)-2003》.pdf EN ISO 16035-2005 en Animal and vegetable fats and oils Determination of low-boiling halogenated hydrocarbons in edible oils《动物和植物脂肪和油 食用油中低沸点卤代烃的测定 (ISO 16035)-2003》.pdf
  • EN ISO 16047-2005 en Fasteners - Torque clamp force testing (Incorporates Amendment A1 2012)《紧固件 扭矩 夹持力试验 ISO 16047-2005》.pdf EN ISO 16047-2005 en Fasteners - Torque clamp force testing (Incorporates Amendment A1 2012)《紧固件 扭矩 夹持力试验 ISO 16047-2005》.pdf
  • 相关搜索

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

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