A conversion operator which converts the current String instance into raw C-style. string of
type const char*.
第1题:
在某类的公共部分有声明string operator++( );和string operator++(int);则说明
A.string operator++( );是前置自增运算符声明
B.string( )perator++( );是后置自增运算符声明
C.string operator++(int);是前置自增运算符声明
D.两条语句无区别
第2题:
Operator overloading operator+= which appends another String instance into current String
instance.
第3题:
已知类 String 的原型为
class string
{
public:
string(const char *str=null);//普通构造函数
string(const string &other);//拷贝构造函数
---string(void);
string &operate=(const string &other);//赋值函数
private:
char * m-data;//用于保存字符串
};
请编写 string 的上述4 个函数
第4题:
编写类 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 个函数。
第5题:
下面哪个是main()方法的合法参数()
A、char args[]
B、char args[][]
C、String arg[]
D、String args
第6题:
语句()能正确完成赋字符串的功能。
第7题:
Given that c is a reference to a valid java.io.Console object, which two code fragments read a line of text from the console?()
第8题:
下面正确声明一个一维数组的是()。
第9题:
Which two create an instance of an array?()
第10题:
Which expressions are correct to declare an array of 10 String objects? ()
第11题:
(a == Hello)
(a == b)
(a == c)
a.equals(b)
a.equals(d)
第12题:
s.equals(t);
t.equals(c);
s==t;
t.equals(new String(hello));
t==c;
第13题:
下列( )语句是声明一个含有10个String对象的数组。
A.char str [];
B.char str [] [];
C.String str[]=new String[10];
D.String str[10];
第14题:
已知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 ;
}
第15题:
下列程序执行后,屏幕上显示的应是 public class Testyyy {public static void main(String[]args) {char charl[]={,'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.true
B.假
C.test
D.编译错误
第16题:
在某类的公共部分有声明string operator++();和string operator++(int);则说明
A.string operator++();是前置自增运算符声明
B.string operator++();是后置自增运算符声明
C.string operator++(int); 是前置自增运算符声明
D.两条语句无区别
第17题:
下面的程序执行后,屏幕上显示的应是 public class Exam{ public static void main(String[]args){ char char1[]='t','e','s','t'}; char char2[]={'t','e','s','t','1',}; String sl=new String(char1); String s2=new String(char2,0,4); System.out.println(S1.equals(s2)); } }
A.真
B.假
C.test
D.编译错误
第18题:
Which expressions will evaluate to true if preceded by the following code?() String a = "hello"; String b = new String(a); String c = a; char[] d = { ’h’, ’e’, ’l’, ’l’, ’o’ };
第19题:
在VB语言中,下列定义变量语句格式正确的是()。
第20题:
下列哪个语句是声明了一个含有10个string对象的数组()。
第21题:
String s= "hello"; String t = "hello"; char c[] = {’h’,’e’,’l’,’l’,’o’} ; Which return true?()
第22题:
Given that c is a reference to a valid java.io.Console object,which two code fragments read a line of textfrom the console?()
第23题:
char str[];
char str[][];
String str[];
String str[10];