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

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

1、计算机二级 JAVA-54及答案解析(总分:100.00,做题时间:90 分钟)一、B基本操作题/B(总题数:3,分数:100.00)1.本程序的功能是找出字符串“My name is Tom, I come from China.“中的大写字母,并打印输出。 public class exam_31 public static void main(String args) String str=“My name is Tom, I come from China.“; _; int i=0; while(ilen) char c=str.charAt(i); if(_) System.out

2、print(c+“ “); _; (分数:30.00)_2.本程序计算两个整数 25和 7的商和余数。 public class exam_32 public static void main(String args) _; num1=25; num2=7; int res1, res2; _; _; System.out.println(num1+“/“+num2+“商:“+res1+“余:“+res2); (分数:30.00)_3.本程序提取字符串“China is a great country.“中的前 5个字符生成一个新的字符串,并将剩余字符组成另外一个新的字符串,最后将两个新的字

3、符串连接输出。 public class exam_33 public static void main(String args) String str=“China is a great country.“; _; headstr=str.substring(_); trailstr=str.substring(_); System.out.println(headstr+trailstr); (分数:40.00)_计算机二级 JAVA-54答案解析(总分:100.00,做题时间:90 分钟)一、B基本操作题/B(总题数:3,分数:100.00)1.本程序的功能是找出字符串“My name

4、is Tom, I come from China.“中的大写字母,并打印输出。 public class exam_31 public static void main(String args) String str=“My name is Tom, I come from China.“; _; int i=0; while(ilen) char c=str.charAt(i); if(_) System.out.print(c+“ “); _; (分数:30.00)_正确答案:(int len=str.length() c=A num1=25; num2=7; int res1, res

5、2; _; _; System.out.println(num1+“/“+num2+“商:“+res1+“余:“+res2); (分数:30.00)_正确答案:(int num1, num2 res1=num1/num2 res2=num1%num2)解析:3.本程序提取字符串“China is a great country.“中的前 5个字符生成一个新的字符串,并将剩余字符组成另外一个新的字符串,最后将两个新的字符串连接输出。 public class exam_33 public static void main(String args) String str=“China is a great country.“; _; headstr=str.substring(_); trailstr=str.substring(_); System.out.println(headstr+trailstr); (分数:40.00)_正确答案:(String headstr, trailstr 0, 5 5, str.length()-1)解析:

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

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

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