String a = “ABCD”; String b = a.toLowerCase(); b.replace(‘a’, ‘d’); b.replace(‘b’, ‘c’); System.out.println(b); What is the result? ()
第1题:
A.String regex="";
B.String regex=" .";
C.String regex=".*";
D.String regex="\\s";
E.String regex="\\.\\s*";
F.String regex="\\w[\.]+";
第2题:
下列程序段运行的结果为 public class Test{ static void print(String s,int i){ System.out.println("String:"+s+",int:"+i); } static void print(int i, String s){ System.out.println("int:"+i+",String:"+s); } public static void main(String [] args){ print(99,"Int first"); } }
A.String:Stringfirst,int:11
B.int:11,String:Int first
C.String:String first,int:99
D.int:99,String:int first
第3题:
已知String类定义如下:
class String
{
public:
String(const char *str = NULL); // 通用构造函数
String(const String &another); // 拷贝构造函数
~ String(); // 析构函数
String & perater =(const String &rhs); // 赋值函数
private:
char *m_data; // 用于保存字符串
};
尝试写出类的成员函数实现。
String::String(const char *str)
{
if ( str == NULL ) //strlen在参数为NULL时会抛
异常才会有这步判断
{
m_data = new char[1] ;
m_data[0] = '\0' ;
}
else
{
m_data = new char[strlen(str) + 1];
strcpy(m_data,str);
}
}
String::String(const String &another)
{
m_data = new char[strlen(another.m_data) + 1];
strcpy(m_data,other.m_data);
}
String& String::operator =(const String &rhs)
{
if ( this == &rhs)
return *this ;
delete []m_data; //删除原来的数据,新开一块内
存
m_data = new char[strlen(rhs.m_data) + 1];
strcpy(m_data,rhs.m_data);
return *this ;
}
String::~String()
{
delete []m_data ;
}
第4题:
Given:Andthefollowingfivefragments:publicstaticvoidmain(String...a){publicstaticvoidmain(String.*a){publicstaticvoidmain(String...a){publicstaticvoidmain(String[]...a){publicstaticvoidmain(String...[]a){Howmanyofthecodefragments,insertedindependentlyatline2,compile?()
A.0
B.1
C.2
D.3
E.4
第5题:
下面哪个是对字符串String的正确定义()。
第6题:
下面哪些语句能够正确地生成5个空字符串?()
第7题:
下面字符串中非法字符串为().
第8题:
在JAVA EE中,request对象的()方法可以获取页面请求中一个表单组件对应多个值时的用户的请求数据。
第9题:
下列Map的泛型声明中正确的是哪项?()
第10题:
11. String test = “Test A. Test B. Test C.”; 12. // insert code here 13. String[] result = test.split(regex); Which regular expression inserted at line 12 will correctly split test into “Test A,” “Test B,” and “Test C”?()
第11题:
第12题:
charAt(int index)
indexOf(String s)
beginWith(String s)
endsWith(String s)
第13题:
下列的哪个程序段可能导致错误? ( )
A.String s="hello"; String t="good"; String k=s+t;
B.String s="hello"; String t; t=s[3]+"one";
C.String s="hello"; String standard=s.toUpperCase();
D.String s="hello"; String t=s+"good";
第14题:
下列字符串中非法字符串为( )。
A.’a string’
B.’It is a’string’.’
C.”a string”
D.”It is a’string”
第15题:
编写类 String 的构造函数、析构函数和赋值函数
已知类 String的原型为:
class String
{
public:
String(const char *str = NULL); // 普通构造函数
String(const String &other); // 拷贝构造函数
~ String(void); // 析构函数
String & perate =(const String &other); // 赋值函数
private:
char *m_data; // 用于保存字符串
};
请编写 String的上述 4 个函数。
第16题:
下面的哪些程序片断可能导致错误()
第17题:
下列不是 String 类的方法的是()
第18题:
执行语句“stringstr("abc");”时,系统会自动调用string类的构造函数()。
第19题:
有声明语句:delegate void TimeDelegate(string s),则以下语句可以和委托TimeDelegate绑定的方法是()
第20题:
String s=new String("xyz");创建了几个String Object?
第21题:
Which of the following fragments might cause errors?()
第22题:
setHeader(String headerName,String headerValue)
setContentType(String mimeType)
setContentLength(int length)
addCookie(Cookie c)
addHeader(String name,String value)
第23题:
String regex = “”;
String regex = “ “;
String regex = “.*“.
String regex = “//s”
String regex = “//.//s*”;
String regex = “//w[ /.] +“;
第24题:
String regex="";
String regex=" .";
String regex=".*";
String regex="//s";
String regex="//.//s*";
String regex="//w[/.]+";