关于以下程序段,正确的说法是()。 String s1=”abc”+”def”; String s2=new String(s1); if(s1= =s2) System.out.println(“= = succeeded”); if (s1.equals(s2)) System.out.println(“.equals() succeeded”);A.行4与行6都将执行B.String s2=new String(s1);C.行6执行,行4不执行D.行6都不执行
关于以下程序段,正确的说法是()。 String s1=”abc”+”def”; String s2=new String(s1); if(s1= =s2) System.out.println(“= = succeeded”); if (s1.equals(s2)) System.out.println(“.equals() succeeded”);
A.行4与行6都将执行
B.String s2=new String(s1);
C.行6执行,行4不执行
D.行6都不执行
参考答案和解析
C编译程序也叫编译系统,是把用高级语言编写的面向过程的源程序翻译成目标程序的语言处理程序。因此答案选
相关考题:
关于以下程序段,正确的说法是() 1.Strings1=”abc” ”def”; 2.Strings2=newString(s1); 3.if(s1==s2) 4.System.out.println(“==succeeded”); 5.if(s1.equals(s2)) 6.System.out.println(“.equals()succeeded”); A.行4与行6都将执行B.行4执行,行6不执行C.行6执行,行4不执行D.行 4、行6都不执行
( 17 )阅读下面程序public class OperatorsAndExpressions {void equalsMethod1(){String s1=new String("how are you");String s2=new String("how are you");System.out.println(s1==s2);}public static void main(String args[]){OperatorsAndExpressions perAndExp=new OperatorsAndExpressions();// 用于复合类型数据的 “ == ” 运算符OperAndExp. equalsMethod1();}}程序运行结果是A ) ==B ) trueC ) falseD ) equal
下面的程序执行后,屏幕上显示的应是 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.编译错误
分析两个字符串,分别输出每个字符串的单词并统计出单词个数。阅读程序,填写空行。注意:不改动程序结构,不得增行或删行。import java.util.*;public class ex2{public static void main(String args[]){String s1="I am Chinese,she is my girlfriend";String s2="Oh,really,fine";StringTokenizer fenxi_1=new StringTokenizer(s1,",");StringTokenizer fenxi_2=new StringTokenizer(s2,",");int n1=fenxi_1.countTokens();int n2=fenxi_2.countTokens();while(fenxi_1.hasMoreTokens()){String s=fenxi_1.nextToken();System.out.println(s);}System.out.println("s1单词:"+n1+"个");while(fenxi_1.hasMoreTokens()){String s=______;System.out.println(s);}System.out.println("s2单词:"+n2+"个");}}
下列语句输出结果为( )。 public class test\ { public static void main (String args[]) { String s1=new String("How"); String s2=new String("How"); System.out.println(!(s1.equals(s2))); } }A.falseB.trueC.0D.1
对于下面的程序includeincludechar *scmp(char*s1,char*s2){if(strcmp(s1, 对于下面的程序 #include<stdio.h> #include<string.h> char *scmp(char*s1,char*s2) { if(strcmp(s1,s2)<0)return(s1); else return(s2); } main() { int i:char string[20],sb[3][20]; for(i=0;i<3;i++)gets(str[i]); strcpy(string,scmp(str[0],str[1])); strcpy(string,scmp(string,str[21)); printf("%s\n",string); } 若运行时依次输入abcd、abba和abc三个字符串,则输出结果为______。A.abcdB.abbaC.abcD.abca
关于以下程序段,正确的说法是( )。(1) String s1="abc"+"def";(2) String s2=new String (s1);(3) if (s1.equals (s2))(4) System.out.println("==succeded");(5) if(s1==s2)(6) System.out.println(".equals( )succeded");A.行(4)与行(6)都将执行B.行(4)执行,行(6)不执行C.行(6)执行,行(4)不执行D.行(4)、行(6)都不执行
下列程序段: String s1=new String("How"); String s2=new String("How"); System.out.println(!(s1==s2)); 的结果为A.falseB.trueC.1D.0
下列程序的执行结果是______。 public class Test9 { public static void main(String[] args) { String s1 = new String("I am a girl"); String s2 = new String("I am a girl"); System.out.println (s1.equal (s2)); } }A.trueB.假C.I amgirlD.都不正确
阅读下面程序 public class OperatorsAndExpressions{ void equalsMethodl(){ String s1=new String("how are you"); String s2=new String("how are you"); System.out.println(s1==s2); } public static void main(String args[]){ OperatorsAndExpressionsOperAndExp=new OperatorsAndExpressions(); //用于复合类型数据的“==”运算符 OperAndExp.equalsMethod1(); } } 程序运行结果是A.=B.trueC.falseD.equal
阅读下面程序 public class OperatorsAndExpressions { void equalsMethodl() { String s1=new String("how are you"); String s2=new String("how are you"); System.out.println(s1==s2); } public static void main(String args[]) { OperatorsAndExpressions perAndExp=new OperatorsAndExpressions(); //用于复合类型数据的“==”运算符 OperAndExp.equalsMethodl(); } } 程序运行的结果是A. ==B.trueC.falseD.equal
下列语句输出结果为( )。 public class test { public static void main(String args[]) String s1 =newString("HOW"); String s2=newString("How"): System.out.pnntln(!(s1.equals(s2))); } }A.假B.真C.0D.1
下列代码的执行结果是( )。 public class Test{ public static void main String args[]){ String s1=new String("welcome"); String s2=new String("welcome"); System.out.println(s1==s2); System.out.println(s1.equals(s2)); } }A.false,falseB.false,trueC.true,trueD.true,false
下面的程序执行后,屏幕上应显示______。 public class Test{ 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.编译错误
阅读下面程序 public class OperatorsAndExpressions { void equalsMethodl(){ String s1=new String("how are you"); String s2=new String("how are you"); System.out.println(s1==s2); } public static void main(String args[]){ OperatorsAndExpressions perAndExp=new OperatorsAndExpressions(); OperAndExp.equalsMethod1(); } } 程序运行结果是( )。A. ==B.trueC.假D.equal
下列语句输出结果为( )。 public class test { public static void main(StringArgsl[]) { String s1=new String("How"); String s2=new String("How"); System.out.println(!(s1==s2)); } }A.falseB.trueC.1D.0
下列代码段的执行结果是( )。 public class Test { public static void main(String args[ ]) { String s1= new String("hello"); String s2= new String("hello"); System.out.println(s1==s2); System.out.println(s1.equal(s2)); } }A.true falseB.true trueC.false trueD.false false
有如下代码段 public class OperatorAndExceptions { public static void main(String args[ ] { int i=10,j=15; System.out.println(i==j); String s1 = new String("how are you!"); String s2=new String("how are you!"); System.out.println(s1==s2); } } 其输出为( )。A.true falseB.true trueC.false trueD.false false
下列语句输出结果为( )。public class test{public static void main(String args []){String s1=new String("How");String s2=new String("How");System.out.println(!(s1 ==s2));}A.falseB.trueC.1D.0
下列代码的执行结果是______。 public class ex55 { public static void main(String args[] ) { String s1=new String("hello"); String s2=new String("hello"); System.out.print (s1==s2); System.out.print (","); System.out.println (s1.equals (s2)); } }A.true, falseB.true, trueC.false, trueD.false, false
阅读下面程序 public class Operators And Expressions( void equals Methodl{ Stringsl一new String("how are you"); Strings2=new String("how are you"); System.out.println(s1= =s2): } public static void main(String args[]){ Operators And Expressions Oper And Exp=new Oper- ators And Expressions ; //用于复合类型数据的”= =”运算符 OperAndExp.equalsMethodl; } } 程序运行结果是( )。A.= =B.trueC.falseD.equal
下面程序执行后,屏幕上显示的应是( )。 public class Test{ public static void main(String[ ] args) { char ch1[]={'B','e','i','j','i','n','g'}; char ch2[]={'B','e','i','j','i','n','g','2','0','0','8'}; String s1 = new String(ch1); String s2 = new String(ch2, 0, 7); System.out.println(sl.equals(s2)); } }A.trueB.falseC.BeijingD.编译错误
下列程序的执行结果为 Private Sub Commandl_Click() Dim s1 As String ,s2 As String s1= "abcd" Call Transfer(sl,s2) Print s2 End Sub Private Sub Transfer (ByVal xstr As String,ystr As String) Dim tempstr As String ystr=tempstr End SubA.dcbaB.abdcC.abcdD.dabc
关于以下程序段,正确的说法是1. String s1="Hello";2. String s2="Hello";3. if(s1= =s2、4. System.out.println("s1= =s2");5. if (s1.equals(s2、)6. System.out.println("s1.equals(s2、");A. 行4与行6都将执行B. 行4执行,行6不执行C. 行6执行,行4不执行D. 行4、行6都不执行
class Sock2 { String color; public boolean equals(Object o) { return color.equals(((Sock2)o).color); } } class TestSocks { public static void main(String [] args) { Sock2 s1 = new Sock2(); s1.color = "blue"; Sock2 s2 = new Sock2(); s2.color = "blue"; if (s1.equals(s2)) System.out.print("equals "); if (s1 == s2) System.out.print("== "); } } 结果为:() A、==B、equalsC、equals ==D、无结果输出
单选题class Sock2 { String color; public boolean equals(Object o) { return color.equals(((Sock2)o).color); } } class TestSocks { public static void main(String [] args) { Sock2 s1 = new Sock2(); s1.color = "blue"; Sock2 s2 = new Sock2(); s2.color = "blue"; if (s1.equals(s2)) System.out.print("equals "); if (s1 == s2) System.out.print("== "); } } 结果为:()A==BequalsCequals ==D无结果输出
判断题使用String s1=new String("Java");String s2=new String("Java")创建两个字符串时,s1,s2使用不同的内存空间A对B错