请问如下哪些语句正确?(多选) A: String s1=”abc”; String s2=”abc”;则s1= =s2 B: String[] s=”abc”; C: new String s=”abc”; D: String s=new String(“abc”);A.String s1=”abc”; String s2=”abc”;则s1= =s2B.String[] s=”abc”;C.new String s=”abc”;D.String s=new String(“abc”);
请问如下哪些语句正确?(多选) A: String s1=”abc”; String s2=”abc”;则s1= =s2 B: String[] s=”abc”; C: new String s=”abc”; D: String s=new String(“abc”);
A.String s1=”abc”; String s2=”abc”;则s1= =s2
B.String[] s=”abc”;
C.new String s=”abc”;
D.String s=new String(“abc”);
参考答案和解析
数据定义
相关考题:
设已包含头文件,下列程序段的运行结果是()。char s1[]={"ACDEF"};char s2[]="ABC";strc 设已包含头文件<string.h>,下列程序段的运行结果是( )。 char s1[]={"ACDEF"}; char s2[]="ABC"; strcpy(s1,s2); printf("%d",strlen(s1));A.3B.4C.6D.5
( 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
已知string s=“123456“,s1=“de“;,则下列选项中正确的语句包括()。 A.s.insert(s.begin()+1,s1)B.s.insert(s.begin()+1,'p')C.s.insert(s.begin()+1,"abc")D.s.insert(1,"abc")
下列语句输出结果为( )。 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
以下程序中函数scmp的功能是返回形参指针s1和s2所指字符串中较小字符串的首地址#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], str[3][20];for(i=0;i3;i++) gets(str[i]);strcpy(string,scmp(str[0],str[1])); /*库函数strcpy对字符串进行复制*/strcpy(string,scmp(string,str[2]));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
以下程序中函数scmp功能是返回形参指针s1和s2所指字符串中较小字符串的首地址。#includ<string. h>char *scmp(char *s1,char *s2){ if(strcmp(s1,s2)<0) return(s1); else return(s2);}main(){ int i;char string[20],str[3][20]; for(i=0;i<3;i++) gets(str[i]); strcpy(string,scmp(str[0],str[1])); //库函数 strcpy 对字符串进行复制 strcpy(string,scmp(stfing,str[2])); puts(string); }若运行时依次输入: abed、abba 和abc三个字符串,则输出结果为( )。A.abedB.abbaC.abcD.abca
以下程序的输出结果是()includemain(){chars1[]="123",s2[]="abc",ss[20]="010";strc 以下程序的输出结果是 ( ) #include<string.h> main() {char s1[]="123",s2[]="abc",ss[20]="010"; strcat(ss+1,strcpy(s2,s1)); printf("%s\n",ss); }A.10123B.0abcC.1123D.01abc
下列程序的执行结果是______。 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.都不正确
对于下面的程序includeincludechar * scmp(char * s1,char * s2){if(strcm 对于下面的程序 #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],str[3][20]; for(i=0;i<3;i++)gets(str[i]); strcpy(string,scmp(str[0],str[1])); strcpy(string,scmp(string,str[2])); printf("%s\n",string); } 若运行时依次输入abcd、abba和abc三个字符串,则输出结果为 ______。A.abcdB.abbaC.abcD.abca
阅读下面程序 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 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 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
设已包含头文件,下列程序段的运行结果是()。 char s1[]={"ACDEF"}; char s2[]="ABC"; s 设已包含头文件<string.h>,下列程序段的运行结果是( )。char s1[]={"ACDEF"};char s2[]="ABC";strcpy(s1,s2) ;printf("%d",strlen(s1) );A.3B.4C.6D.5
下列代码的执行结果是______。 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
下面哪个是对字符串String的正确定义()。A、String s1=null;B、String s2=’null’;C、String s3=(String)‘abc’;D、String s4=(String)‘/uface’;
执行语句“stringstr("abc");”时,系统会自动调用string类的构造函数()。A、string()B、string(constchar*s)C、string(conststringstr)D、string(size_typen,charc)
import java.util.*; public class WrappedString { private String s; public WrappedString(String s) { this.s = s; } public static void main(String[] args) { HashSet hs = new HashSet(); WrappedString ws1 = new WrappedString(”aardvark”); WrappedString ws2 = new WrappedString(”aardvark”); String s1 = new String(”aardvark”); String s2 = new String(”aardvark”); hs.add(ws1); hs.add(ws2); hs.add(s1); hs.add(s2); System.out.println(hs.size()); } } What is the result?() A、 0B、 1C、 2D、 3E、 4F、 Compilation fails.G、 An exception is thrown at runtime.
Given: 22.StringBuilder sb1 = new StringBuilder("123"); 23.String s1 = "123"; 24.// insert code here 25.System.out.println(sb1 + " " + s1); Which code fragment, inserted at line 24, outputs "123abc 123abc"?()A、sb1.append("abc"); s1.append("abc");B、sb1.append("abc"); s1.concat("abc");C、sb1.concat("abc"); s1.append("abc");D、sb1.concat("abc"); s1.concat("abc");E、sb1.append("abc"); s1 = s1.concat("abc");
单选题下面哪个是对字符串String的正确定义()。AString s1=null;BString s2=’null’;CString s3=(String)‘abc’;DString s4=(String)‘/uface’;