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

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

1、计算机二级 JAVA-56及答案解析(总分:100.00,做题时间:90 分钟)一、B基本操作题/B(总题数:3,分数:100.00)1.本程序统计字母 m在字符串“I am Tom, I am from China.“中出现的次数。 public class exam_37 public static void main(String args) String str=“I am Tom, I am from China.“; char c=m; int i; int sum=0; for(_) _; if(c=temp) _; System.out.println(str+“中“+c+“出

2、现了“+sum+“次“); (分数:30.00)_2.本程序判断一个字符串“Tom“是否在另外一个字符串“I am Tom, I am from China.“中出现。 public class exam_38 public static void main(String args) _; str1=:I am Tom, I am from China.“; str2=“Tom“; int i=_; if(_) System.out.println(“+str2+“is in the string:“+str1+“); else System.out.println(“+str2+“is no

3、t in the string:“+str1+“); (分数:30.00)_3.本程序的功能是将输入的字符串转换为实数,并打印输出。 import java.io.*; public class exam_39 public static void main(String args) InputStreamReader ir; BufferedReader in; ir=new InputStreamReader(_); in=new BufferedReader(ir); double d=0.0; System.out.print(“请输一个实数:“); _ String s=in.rea

4、dLine(); _; catch(Exception e) System.out.println(“你输入的实数是:“+d); (分数:40.00)_计算机二级 JAVA-56答案解析(总分:100.00,做题时间:90 分钟)一、B基本操作题/B(总题数:3,分数:100.00)1.本程序统计字母 m在字符串“I am Tom, I am from China.“中出现的次数。 public class exam_37 public static void main(String args) String str=“I am Tom, I am from China.“; char c=m

5、 int i; int sum=0; for(_) _; if(c=temp) _; System.out.println(str+“中“+c+“出现了“+sum+“次“); (分数:30.00)_正确答案:(i=0; istr. length(); i+ char temp=str. charAt(i) sum+(或 sum=sum+1或 sum+=1)解析:2.本程序判断一个字符串“Tom“是否在另外一个字符串“I am Tom, I am from China.“中出现。 public class exam_38 public static void main(String args)

6、 _; str1=:I am Tom, I am from China.“; str2=“Tom“; int i=_; if(_) System.out.println(“+str2+“is in the string:“+str1+“); else System.out.println(“+str2+“is not in the string:“+str1+“); (分数:30.00)_正确答案:(String str1, str2 str1. indexOf (str2) i!=-1)解析:3.本程序的功能是将输入的字符串转换为实数,并打印输出。 import java.io.*; pub

7、lic class exam_39 public static void main(String args) InputStreamReader ir; BufferedReader in; ir=new InputStreamReader(_); in=new BufferedReader(ir); double d=0.0; System.out.print(“请输一个实数:“); _ String s=in.readLine(); _; catch(Exception e) System.out.println(“你输入的实数是:“+d); (分数:40.00)_正确答案:(System.in try d=Double.parseDouble (s)解析:

展开阅读全文
相关资源
猜你喜欢
相关搜索

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

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