一、基本操作题(共1题,合计18分)
41本题是判断一个字符串“Tom”是否在另外一个字符串“I am Tom,I am from China”中出现。
public class javal{
public static void main(String[]args){
;
strl="I am Tom,I am from China.";
str2="Tom";
int i= ;
if( )
System.out.println("\"+str2+"\"is in the
string:\""+strl+"\"");
else
System.out.println("\""+str2+"\"is not in the
string:\""+strl+"\"");
}
}
[正确答案]第1处:String strl,str2
第2处:strl.indexOf(str2)
第3处:i!=-1
【解析】第1处使用前定义变量strl和str2;第2处和第3处判断str2是否是strl的子串。[您的答案] int i = strl.indexOf("Tom"); if(i != -1)
本题分值:18分您的得分:10分
试题解析:
+我要找茬+加入错题+收藏该题评论此题
三、应用题(共1题,合计24分)
42本题要求分行打印输出当前系统中所有字体的名称。
;
public class java2
{
public static void main(String[]args)
{
String[]fontNames=GraphicsEnvironment
.getLocalGraphicsEnvironment().getAvailable-