下面的哪些程序片断可能导致错误?()
A: Strings=“Gonewiththewind”;Stringt=“good“;Stringk=s+t;
B: Strings=“Gonewiththewind”;Stringt;t=s[3]+“one”;
C: Strings=“Gonewiththewind”;Stringstandard=s.toUpperCase();
D: Strings=“homedirectory”;Stringt=s–“directory”;
A: Strings=“Gonewiththewind”;Stringt=“good“;Stringk=s+t;
B: Strings=“Gonewiththewind”;Stringt;t=s[3]+“one”;
C: Strings=“Gonewiththewind”;Stringstandard=s.toUpperCase();
D: Strings=“homedirectory”;Stringt=s–“directory”;
举一反三
- 已知Strings=“Java”,则下面哪些代码是正确的() A: s=s+1; B: charc=s[3]; C: inti=s.length; D: Stringt=s+newObject();
- (10_3)有语句Strings=”helloworld”,以下操作合法的是()。 A: inti=s.length(); B: Strings2=s.trim(); C: s>>>=3; D: Stringt=s+”!;”
- 下面的哪些程序片断可能导致错误() 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: Strings=“你好”;inti=3;s+=i; B: Strings=“你好”;inti=3;if(i==s)s+=i; C: Strings=“你好”;inti=3;s=i+s; D: Strings=“你好”;inti=3;s=i+;
- 下面的表达式哪些是正确的?() A: Strings="你好";inti=3;s+=i; B: Strings="你好";inti=3;if(i==s){s+=i}; C: Strings="你好";inti=3;s=i+; D: Strings="0";inti=(s!=null)&&(s.length()>0)?s.length():0;