【计算机类职业资格】计算机二级JAVA-123 (1)及答案解析.doc

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

1、计算机二级 JAVA-123 (1)及答案解析(总分:100.00,做题时间:90 分钟)一、基本操作题(总题数:3,分数:100.00)1.本程序定义了一个方法 add(),用于求两个整型数的和。方法中有两个整型参数 a 和 b,方法体中计算a 和 b 的和 sum,并将结果返回。程序中调用 add()方法求整数 24 和 34 的和,并将结果打印输出。 public class exam_28 public static void main(String args) int a=24, b=34; System.out.println(add(a,b); public static int

2、 add(_) _; sum=a+b; _; (分数:30.00)_2.本程序的功能是随机产生一个 110 间的随机数,根据提示用户可以猜这个随机数。例如,程序随机产生的随机数是 7,如果输入 8,则提示“Try smaller.”并继续提示输入,如果输出 6,则提示“Try bigger.”并继续提示输入,如果输入 7,则输出“Great!”并退出程序。 import java.io.*; public class exam_29 public static void main(String args) InputStreamReader ir; BufferedReader in; ir=

3、new InputStreamReader(System.in); in=new BufferedReader(ir); int ranNum=_; int guessNum=-1; String str; while(_) System.out.print(“Please Input:“); try _; guessNum=Integer.parseInt(str); catch(Exception e) if(guessNumranNum) System.out.println(“Try smaller.“); else System.out.println(“Try bigger.“);

4、 System.out.println(“Great!“); (分数:30.00)_3.本程序的功能是统计成绩不及格的人数,分数有 56,90,89,23,45,61,60,59。 public class exam_30 public static void main(String args) int score=56,90,89,23,45,61,60,59; int num=0; _; int i=0; while(_) if(_) sum+; i+; System.out.println(“60:“+sum); (分数:40.00)_计算机二级 JAVA-123 (1)答案解析(总分:

5、100.00,做题时间:90 分钟)一、基本操作题(总题数:3,分数:100.00)1.本程序定义了一个方法 add(),用于求两个整型数的和。方法中有两个整型参数 a 和 b,方法体中计算a 和 b 的和 sum,并将结果返回。程序中调用 add()方法求整数 24 和 34 的和,并将结果打印输出。 public class exam_28 public static void main(String args) int a=24, b=34; System.out.println(add(a,b); public static int add(_) _; sum=a+b; _; (分数:

6、30.00)_正确答案:()解析:int a, int b int sum return sum2.本程序的功能是随机产生一个 110 间的随机数,根据提示用户可以猜这个随机数。例如,程序随机产生的随机数是 7,如果输入 8,则提示“Try smaller.”并继续提示输入,如果输出 6,则提示“Try bigger.”并继续提示输入,如果输入 7,则输出“Great!”并退出程序。 import java.io.*; public class exam_29 public static void main(String args) InputStreamReader ir; Buffered

7、Reader in; ir=new InputStreamReader(System.in); in=new BufferedReader(ir); int ranNum=_; int guessNum=-1; String str; while(_) System.out.print(“Please Input:“); try _; guessNum=Integer.parseInt(str); catch(Exception e) if(guessNumranNum) System.out.println(“Try smaller.“); else System.out.println(“

8、Try bigger.“); System.out.println(“Great!“); (分数:30.00)_正确答案:()解析:(int) (Math.random() *10) guessNum!=ranNum str=in.readLine()3.本程序的功能是统计成绩不及格的人数,分数有 56,90,89,23,45,61,60,59。 public class exam_30 public static void main(String args) int score=56,90,89,23,45,61,60,59; int num=0; _; int i=0; while(_) if(_) sum+; i+; System.out.println(“60:“+sum); (分数:40.00)_正确答案:()解析:int sum=0 iscore.length score i60(或 score i=59)

展开阅读全文
相关资源
猜你喜欢
  • KS M ISO 11093-2-2008 Paper and board-Testing of cores-Part 2:Conditioning of test samples《纸和纸板 硬纸板锥形圆筒的检验 第2部分 试样的条件》.pdf KS M ISO 11093-2-2008 Paper and board-Testing of cores-Part 2:Conditioning of test samples《纸和纸板 硬纸板锥形圆筒的检验 第2部分 试样的条件》.pdf
  • KS M ISO 11093-4-2008 Paper and board-Testing of cores-Part 4:Measurement of dimensions《纸和纸板 硬纸板锥形圆筒的检验 第1部分 尺寸测量》.pdf KS M ISO 11093-4-2008 Paper and board-Testing of cores-Part 4:Measurement of dimensions《纸和纸板 硬纸板锥形圆筒的检验 第1部分 尺寸测量》.pdf
  • KS M ISO 11093-9-2008 Paper and board-Testing of cores-Part 9:Determination of flat crush resistance《纸和纸板 硬纸板锥形圆筒的检验 第9部分 抗压扁性的测定》.pdf KS M ISO 11093-9-2008 Paper and board-Testing of cores-Part 9:Determination of flat crush resistance《纸和纸板 硬纸板锥形圆筒的检验 第9部分 抗压扁性的测定》.pdf
  • KS M ISO 11127-2-2012 Preparation of steel substrates before application of paints and related products-Test methods for non-metallic blast-cleaning abrasives-Part 2:Determination .pdf KS M ISO 11127-2-2012 Preparation of steel substrates before application of paints and related products-Test methods for non-metallic blast-cleaning abrasives-Part 2:Determination .pdf
  • KS M ISO 11158-2011 Lubricants industrial oils and related products(class L)-Family H(hydraulic systems)-Specifications for categories HH HL HM HR HV and HG《润滑油、工业用油和有关产品(L类) H族(液压.pdf KS M ISO 11158-2011 Lubricants industrial oils and related products(class L)-Family H(hydraulic systems)-Specifications for categories HH HL HM HR HV and HG《润滑油、工业用油和有关产品(L类) H族(液压.pdf
  • KS M ISO 11193-2-2009 Single-use medical examination gloves-Part 2:Specification for gloves made from poly(vinyl chloride)《一次性医用检查手套 第2部分 聚乙烯(氯乙烯)制成的手套规范》.pdf KS M ISO 11193-2-2009 Single-use medical examination gloves-Part 2:Specification for gloves made from poly(vinyl chloride)《一次性医用检查手套 第2部分 聚乙烯(氯乙烯)制成的手套规范》.pdf
  • KS M ISO 11234-2007 Rubber compounding ingredients-Carbon black(pelletized)-Determination of dust content《橡胶配合剂 炭黑(造粒) 粉尘含量测定》.pdf KS M ISO 11234-2007 Rubber compounding ingredients-Carbon black(pelletized)-Determination of dust content《橡胶配合剂 炭黑(造粒) 粉尘含量测定》.pdf
  • KS M ISO 11236-2007 Rubber compounding ingredients-p-Phenylenediamine(PPD) antidegradants-Test methods《橡胶配合剂-p-对苯二胺防老剂 试验方法》.pdf KS M ISO 11236-2007 Rubber compounding ingredients-p-Phenylenediamine(PPD) antidegradants-Test methods《橡胶配合剂-p-对苯二胺防老剂 试验方法》.pdf
  • KS M ISO 11237-2012 Rubber hoses and hose assemblies- Compact wire-braid-reinforced hydraulic types for oil-based or water-based fluids-Specification《橡胶管与软管组件 油性或水性流体用紧凑钢丝编织增强油压类型 .pdf KS M ISO 11237-2012 Rubber hoses and hose assemblies- Compact wire-braid-reinforced hydraulic types for oil-based or water-based fluids-Specification《橡胶管与软管组件 油性或水性流体用紧凑钢丝编织增强油压类型 .pdf
  • 相关搜索

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

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