网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
多选题
Which of the following fragments might cause errors?()
A

String s = Gone with the wind;String t =  good ;String k = s + t;

B

String s = Gone with the wind;String t;t = s[3] + one;

C

String s = Gone with the wind;String standard = s.toUpperCase();

D

String s = home directory;String t = s - directory;


参考答案

参考解析
解析: A:String类型可以直接使用+进行连接运算。 
B:String是一种Object,而不是简单的字符数组,不能使用下标运算符取其值的某个元素,错误。 
C://toUpperCase()方法是String对象的一个方法,作用是将字符串的内容全部转换为大写并返回转换后的结果(String类型)。    
D://String类型不能进行减(-)运算,错误。
更多 “多选题Which of the following fragments might cause errors?()AString s = Gone with the wind;String t =  good ;String k = s + t;BString s = Gone with the wind;String t;t = s[3] + one;CString s = Gone with the wind;String standard = s.toUpperCase();DString s = home directory;String t = s - directory;” 相关考题
考题 下面的哪些程序段可能导致错误? ( ) Ⅰ: String s = "Gone with the wind"; String t = "good "; String k = s + t; Ⅱ: String s = "Gone with the wind"; String t; t = s[3] + "one"; Ⅲ: String s = "Gone with the wind"; String standard = s.toUpperCase(); Ⅳ: String s = "home directory"; String t = s-"directory":A.Ⅱ、ⅢB.Ⅱ、ⅣC.Ⅰ、ⅣD.Ⅲ、Ⅳ

考题 假设有以下代码: String s="hello"; String t="hello"; char c[ ]={'h','e','l','l','o'}; 下列选项中,返回false的语句是______。A.s.equals(t);B.t.equals(c);C.s==t;D.t.equals(new String("hello"));

考题 给出下面的代码,则以下( )选项返回true。 String s="hello"; String t="hello"; Char c[]={'h','e','l','l','o'};A.s. equals (t) ;B.t. equals (C);C.s==t;D.t==c;

考题 下面的程序执行后,屏幕上显示的应是 public class Exam{ public static void main(String[]args){ char char1[]={'t','e','s','t'}; char char2[]={'t','e','S','t','1'}; String s1=new String(char1); String s2=new String(char2,0,4); System.out.println(s1.equals(s2)); } }A.trueB.falseC.testD.编译错误

考题 String s=”Example String”; 下面哪些语句是正确的?() A.s>>>=3;B.int i=s.length();C.s[3]=”x”;D.String short_s=s.trim();E.String t=”root”+s;

考题 有以下等程序include void f(char *s, char *t){ chark; k=*s; *s=*t; *t=k; s++;t- 有以下等程序#include <string. h>void f(char *s, char *t){ char k; k=*s; *s=*t; *t=k; s++; t--; if(*s) f(s, t);}main (){ char stt[10] ="abcdefg", *p; p=str+strlen (str)/2+1; f (p,p-2); print f ( "%s\n", str);}A.abcdefgB.gfedcbaC.gbcdefaD.abedcfg

考题 下列的哪个程序段可能导致错误? ( )A.String s="hello"; String t="good"; String k=s+t;B.String s="hello"; String t; t=s[3]+"one";C.String s="hello"; String standard=s.toUpperCase();D.String s="hello"; String t=s+"good";

考题 下列哪个程序段可能导致错误?A.String s="hello"; String t= "good"; String k=s+ t;B.String s="hello"; String t; t=s[3]+"one";C.String s="hello"; String standard=s. toUpperCaseD.String s="hello"; String t =s+ "good"

考题 给出下列的代码则以下哪个选项返回true? String s = "hello" ; String s = "hello" ; char c[] = { 'h' ,'e','l','o'};A.s.equals(t);B.t.equals(c);C.s = =tD.t = = c;

考题 下面的程序执行后,屏幕上显示的应是 public class Exam{ public static void main(String[]args){ char char1[]='t','e','s','t'}; char char2[]={'t','e','s','t','1',}; String sl=new String(char1); String s2=new String(char2,0,4); System.out.println(S1.equals(s2)); } }A.真B.假C.testD.编译错误

考题 下列的( )程序段可能导致错误。A.String s="hello": Sting t="good"; String k=s+t;B.Sting s="hello"; String t; t=s [3] + "one";C.Sting s="hello"; String standard=s.toUpperCase( );D.String s="hello": Stringt s +"good";

考题 下列的哪个程序段可能导致错误?A.String s = "hello"; String t = "good"; String k = s + t;B.String s = "hello"; String t; t = s[3] + "one";C.String s = " hello "; String standard = s.toUpperCase( );D.String s = "hello"; String t = s + "good";

考题 下面的哪些程序片断可能导致错误() A、String s = "Gone with the wind";  String t = " good ";  String k = s + t;B、String s = "Gone with the wind";  String t;  t = s[3] + "one";C、String s = "Gone with the wind";  String standard = s.toUpperCase();D、String s = "home directory"; String t = s - "directory"

考题 public String makinStrings() {  String s = “Fred”;  s = s + “47”;  s = s.substring(2, 5);  s = s.toUpperCase();  return s.toString();  }  How many String objects will be created when this method is invoked?() A、 1B、 2C、 3D、 4E、 5F、 6

考题 Strings="This is the";Stringt=s.concat("String.");t的内容是()A、This is the StringB、This is theC、String

考题 有语句String s=”hello world”; ,以下操作哪个是不合法的()A、int i=s.length();B、s=3;C、String ts=s.trim();D、String t=s+”!”

考题 现有:  import java.util.*;      class AddStuff2  {  public static void main(String  []  args)  {      TreeSett=new TreeSet();      if (t.add("one"))      if (t.add("two"))     if (t.add ("three"))  add("four");  for (String s  :  t)      System.out.print (s);     }      }      结果为:()     A、 oneB、 one three twoC、 one two threeD、 one two three fourE、 four one three twoF、编译失败

考题 String s= "hello";     String t = "hello";  char c[] = {’h’,’e’,’l’,’l’,’o’} ;     Which return true?()   A、 s.equals(t);B、 t.equals(c);C、 s==t;D、 t.equals(new String("hello"));E、 t==c;

考题 Which of the following fragments might cause errors?()    A、 String s = "Gone with the wind";String t = " good ";String k = s + t;B、 String s = "Gone with the wind";String t;t = s[3] + "one";C、 String s = "Gone with the wind";String standard = s.toUpperCase();D、 String s = "home directory";String t = s - "directory";

考题 单选题有语句String s=”hello world”; ,以下操作哪个是不合法的()A int i=s.length();B s=3;C String ts=s.trim();D String t=s+”!”

考题 多选题下面的哪些程序片段可能导致错误()。AString s = “Gone with the wind”;  String t = “ good”;  String k = s + t;BString s = “Gone with the wind”;  String t;  t = s[3] + “one”;CString s = “Gone with the wind”;  String standard = s.toUpperCase();DString s = “home directory”;  String t = s – “directory”;

考题 多选题下面哪段语法执行正确()AString s = Gone with the wind;String t =  good ;String k = s + t;BString s = Gone with the wind;String t; t = s[3] + one;CString s = Gone with the wind;String standard = s.toUpperCase();DString s = home directory;String t = s - directory;

考题 单选题执行语句“stringstr("abc");”时,系统会自动调用string类的构造函数()。A string()B string(constchar*s)C string(conststringstr)D string(size_typen,charc)

考题 单选题Given: 11.String test = "Test A. Test B. Test C."; 12.// insert code here 13.String[] result = test.split(regex); Which regular expression, inserted at line 12,correctly splits test into "Test A","Test B",and "Test C"?()A String regex = ;B String regex =  ;C String regex = .*;D String regex = //s;E String regex = //.//s*;

考题 单选题public String makinStrings() {  String s = “Fred”;  s = s + “47”;  s = s.substring(2, 5);  s = s.toUpperCase();  return s.toString();  }  How many String objects will be created when this method is invoked?()A  1B  2C  3D  4E  5F  6

考题 多选题String s= "hello";     String t = "hello";  char c[] = {’h’,’e’,’l’,’l’,’o’} ;     Which return true?()As.equals(t);Bt.equals(c);Cs==t;Dt.equals(new String(hello));Et==c;

考题 单选题下面哪个是对字符串String的正确定义()。A String s1=null;B String s2=’null’;C String s3=(String)‘abc’;D String s4=(String)‘/uface’;