If your program needs to make a lot of changes to one or more string,you might consider using objects of this class: (如果你的程序需要进行一个或多个字符串的修改,你需要考虑下列哪个类的对象:)
A. Character
B. String
C. StringBuilder
D. All of the above
查看答案
Look at the following statement: (请看下列语句:)StringBuilder str = new StringBuilder(25);What will the StringBuilder constructor do? (StringBuilder构造函数将做什么?)
A. give the object, str, 25 bytes of storage and store spaces in them (给对象str,25字节的存储及其存储空间)
B. give the object, str, 25 bytes of storage and not store anything in them (给对象str,25字节的存储并不在其中存储任何东西)
C. give the object, str, 25 or more bytes of storage and store spaces in them(给对象str,25或更多字节的存储及其存储空间)
D. give the object, str, 0 bytes of storage (给对象str,0字节的存储)
What would be the results of executing the following code? (下列代码的运行结果是?)StringBuilder str = new StringBuilder("Little Jack Horner "); str.append("sat on the ");str.append("corner");
A. The program would crash. (程序会崩溃)
B. str would reference "Little Jack Horner ". (str为“Little Jack Horner”)
C. str would reference "Little Jac Horner sat on the ". (str为“Little Jac Horner sat on the”)
D. str would reference "Little Jack Horner sat on the corner".(str为“Little Jack Horner sat on the corner”)
When using the StringBuilder class's insert method,you can insert: (使用StringBuilder类的insert方法时,可以插入:)
A. any primitive type (任何基本类型)
B. a String object(字符串对象)
C. a char array(一个字符数组)
D. All of the above
What will be the value of str after the following statements are executed? (执行下列语句后,str的值将是多少?)StringBuilder str =new StringBuilder("We have lived in Chicago, " +"Trenton, and Atlanta."); str.replace(17, 24, "Tampa");
A. We have lived in Tampa, Trenton, and Atlanta.
B. We have lived in Chicago, Tampa, and Atlanta.
C. We have lived in Tampa Trenton, and Tampa.
D. We have lived in Tampalanta.