判断题String str="abcedf"; int length=str.length。A对B错

判断题
String str="abcedf"; int length=str.length。
A

B


参考解析

解析: 暂无解析

相关考题:

阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【说明】字符串在程序设计中扮演着重要角色。现需要设计字符串基类string,包含设置字 符串、返回字符串长度及内容等功能。另有一个具有编辑功能的串类edlt_string,派生于string,在其中设置一个光标,使其能支持在光标处的插入、删除操作。【程序】include <iostream.h>include <stdio.h>include <string.h>class string{int length;char *data;public:int get_length() {return length;}char *get_data() {return data;}~string() {delete data;}int set data(int in_length, char *in_data);int set_data(char *data);void print() {cout<<data<<endl;}};class edit_string: public string{int cursor;public:int get_cursor() {return cursor;}void move_cursor(int dis) {cursor=dis;}int add_data(string *new_data);void delete_data(int num);};int string::set_data(int in_length,char *in_data){length=in_length;if(!data)delete data;(1)strcpy(data,in_data);return length;}int string::set data(char *in_data){(2)if(!data)delete data;(1)strcpy(data,in_data);return length;}int edit_string::add_data(string *new_data){int n,k,m;char *cp,*pt;n=new_data->get_length();pt=new_data->get_data();cp=this->get_data();m=this->get_length();char *news=new char[n+m+1];for(int i=0; i<cursor; i++)news[i]=cp[i];k=i;for(int j=0; j<n; i++,j++)news[i]=pt[j];cursor=i;for(j=k; j<m; j++,i++)(3)news[i]='\0';(4)delete news;return cursor;}void edit string::delete_data( int num){int m;char *cp;cp=this->get_data();m=this->get_length();for(int i=cursor; i<m; i++)(5)cp[i]='\0';}

若输入bcdefgh、m、abcdefg,以下程序的输出结果为()。includeincludemain(){i 若输入bcdefgh、m、abcdefg,以下程序的输出结果为( )。 #include<stdio.h> #include<string.h> main() { int i; char string[20],str[3][20]; for(i=0;i<3;i++)gets(str[i]); if(strcmp(str[0],str[1])>0) strcpy(string,str[0]); else strcpy(string,str[1]); if(strcmp(str[2],string)>0) strcpy(string,str[2]); printf("%s",string); }A.bcdefghB.mC.abcdefgD.bcdefgh或abcdefg

已知String str=new String ("Luck");,则下列关于str的操作中不合法的是( )。A.String s=str. toUpperCase()B.int i=Str. length;C.char s=str. charAt(2);D.String s="Good" +str;

publicstaticvoidtest(Stringstr){intcheck=4;if(check=str.length()){System.out.print(str.charAt(check-=1)+,);}else{System.out.print(str.charAt(0)+,);}}andtheinvocation:test(”four”);test(”tee”);test(”to”);Whatistheresult?()A.r,t,t,B.r,e,o,C.Compilationfails.D.Anexceptionisthrownatruntime.

publicstaticvoidmain(String[]args){Stringstr=null?;if(str==null){System.out.println(”null”);}else(str.length()==0){System.out.println(”zero”);}else{System.out.println(”some”);}}Whatistheresult?() A.nullB.zeroC.someD.Compilationfails.E.Anexceptionisthrownatruntime.

Giventhefollowingcodefragment:1)Stringstr=null;2)if((str!=null)(str.length()10)){3)System.out.println(morethan10);4)}5)elseif((str!=null)(str.length()5)){6)System.out.println(lessthan5);7)}8)else{System.out.println(end);}Whichlinewillcauseerror?()A.line1B.line2C.line5D.line8

阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写对应栏内。【说明】下面的程序实现了类String的构造函数、析构函数和赋值函数。已知类String的原型为:class String{public:String(coust char * str = NULL); //普通构造函数String( const String other); //拷贝构造函数~String(void); //析构函数String perate =(const String other); //赋值函数private:char * m_data; // 用于保存字符串};//String 的析构函数String:: ~String (void){(1);}//String 的普通构造函数String: :String( const char * str){if (2){m_data = new char[1];*m_data = '\0';}else{int length = strlen(str);m_data = new ehar[ length + 1 ];strepy(m_data, str);}}//拷贝的构造函数String:: String( const String other){ int length = strlen(other. m_data);m_data = new char[ length + 1 ];strepy(m_data, other, m_data); //赋值函数String String::operate = (eonst String other) //{if (3)return * this;delete [] m_clara; //释放原有的内存资源int length = strlen( other, m_data);m_data = new chart length + 1 ];(4);return (5);}

阅读下列程序,当运行函数时,输入asd af aa z67,则输出为includeincludeinc 阅读下列程序,当运行函数时,输入asd af aa z67,则输出为 #include<stdio.h> #include<ctype.h> #include<string.h> int fun(char*str) { int i,j=0; for(i=0;str[i]!='\0';i++) if(str[i]!='')str[j++]=str[i]; str[j]='\0'; } main() { char str[81]; int n; clrscr(); printf("Input a string:"); gets(str); puts(str); fun(str); printf("%s\n",str); }A.asdafaaz67B.asdafaaz67C.asdD.z67

4 . 写出程序的输出结果class Class1 {private string str = "Class1.str";private int i = 0;static void StringConvert(string str) {str = "string being converted.";}static void StringConvert(Class1 c) {c.str = "string being converted.";}static void Add(int i) {i++;}static void AddWithRef(ref int i) {i++;}static void Main() {int i1 = 10;int i2 = 20;string str = "str";Class1 c = new Class1();Add(i1);AddWithRef(ref i2);Add(c.i);StringConvert(str);StringConvert(c);Console.WriteLine(i1);Console.WriteLine(i2);Console.WriteLine(c.i);Console.WriteLine(str);Console.WriteLine(c.str);}}

以下( )表达式是不合法的。A.String x="Sky";int y=5;x + =y:B.String x="Sky":int y=5:if(x==y){}C.String x="Sky":int y=5:x=x+y:D.String x=null:int y=(x!=null) (x.length( )>0)?x.length:0

以下( )表达式是不合法的。A.string x="hello";int y=9;x+=y;B.string x="hello";int y=9;if(x=y){}C.string x="hello";int y=9;x=x+y;D.string x=null;inty=(x!=null)(x.length()>0)?x.length():0;

public static void main(String[] args) {  String str = “null‟;  if (str == null) {  System.out.println(”null”);  } else (str.length() == 0) {  System.out.println(”zero”);  } else {  System.out.println(”some”);  }  }  What is the result?()A、 nullB、 zeroC、 someD、 Compilation fails.E、 An exception is thrown at runtime.

String str="abcedf"; int length=str.length。

String str; System.out.println(str.length()); 以上语句运行的结果是显示0 。

设有定义:String s=“World”;,下列语句错误的是()。A、int m=s.indexOf(‘r’);B、char c=s.charAt(0);C、int n=s.length();D、String str=s.append(‘2’);

String date="Today is Sunday.";String str2=data.CharAt(s.length( )-1);则str2为()A、yB、.C、nullD、false

字符串,str="welcometoBeijing"进行下列操作处理,描述结果错误的是()A、str.substring(4,9)返回值是"onet"B、str.length的返回值是"18"C、str.charAt("4")返回值是"e"D、str.toUpperCase()的返回值是"welcometoBeijing"

Given the following code fragment:      1) String str = null;  2) if ((str != null)  (str.length()  10)) {     3) System.out.println("more than 10");     4) }  5) else if ((str != null)  (str.length()  5)) {     6) System.out.println("less than 5");     7) }  8) else { System.out.println("end"); }   Which line will cause error?()    A、 line 1B、 line 2C、 line 5D、 line 8

java中 String str = "hello world"下列语句错误的是()。A、str+=’ a’B、int strlen = str.lengthC、str=100D、str=str+100

public static void main(String[]args){ String str="null"; if(str==null){ System.out.println("null"); }else(str.length()==0){ System.out.println("zero"); }else{ System.out.println("some"); } } What is the result?()A、nullB、zeroC、someD、Compilationfails.E、Anexceptionisthrownatruntime.

public static void test(String str) { int check = 4;  if (check = str.length()) {  System.out.print(str.charAt(check -= 1) +“, “);  } else {  System.out.print(str.charAt(0) + “, “);  }  }  and the invocation:  test(”four”);  test(”tee”); test(”to”);  What is the result?() A、 r, t, t,B、 r, e, o,C、 Compilation fails.D、 An exception is thrown at runtime.

单选题String date="Today is Sunday.";String str2=data.CharAt(s.length( )-1);则str2为()AyB.CnullDfalse

单选题public static void test(String str) { int check = 4;  if (check = str.length()) {  System.out.print(str.charAt(check -= 1) +“, “);  } else {  System.out.print(str.charAt(0) + “, “);  }  }  and the invocation:  test(”four”);  test(”tee”); test(”to”);  What is the result?()A r, t, t,B r, e, o,C Compilation fails.D An exception is thrown at runtime.

单选题Given the following code fragment:      1) String str = null;  2) if ((str != null)  (str.length()  10)) {     3) System.out.println("more than 10");     4) }  5) else if ((str != null)  (str.length()  5)) {     6) System.out.println("less than 5");     7) }  8) else { System.out.println("end"); }   Which line will cause error?()A line 1B line 2C line 5D line 8

判断题String str; System.out.println(str.length()); 以上语句运行的结果是显示0 。A对B错

单选题public static void main(String[] args) {  String str = “null‟;  if (str == null) {  System.out.println(”null”);  } else (str.length() == 0) {  System.out.println(”zero”);  } else {  System.out.println(”some”);  }  }  What is the result?()A nullB zeroC someD Compilation fails.E An exception is thrown at runtime.

单选题public static void main(String[]args){ String str="null"; if(str==null){ System.out.println("null"); }else(str.length()==0){ System.out.println("zero"); }else{ System.out.println("some"); } } What is the result?()AnullBzeroCsomeDCompilationfails.EAnexceptionisthrownatruntime.