下列语句创建了多少个string对象()。string[,]strArray=new string[3][4];
第1题:
阅读下列程序说明和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);
}
第2题:
下列( )语句是声明一个含有10个String对象的数组。
A.char str [];
B.char str [] [];
C.String str[]=new String[10];
D.String str[10];
第3题:
下列语句输出结果为( )。 public class test { public static void main(StringArgsl[]) { String s1=new String("How"); String s2=new String("How"); System.out.println(!(s1==s2)); } }
A.false
B.true
C.1
D.0
第4题:
类Student代码如下: class Student{ String name; int age; Student(String nm){ name = nm; } } 执行语句Student stu = new Student()后,字段age的值是哪项?()
第5题:
下列哪个语句是声明了一个含有10个string对象的数组()。
第6题:
下面关于数组声明和初始化的语句哪个有语法错误()
第7题:
在C#中,下列哪条语句能创建一个具有3个初始值为""的元素的字符串数组?()
第8题:
现有: class TestFoo { int x; String y; int getX() { return x; } String getY() { return y; } void setX(int x) { int z = 7; this.x = x; } } 可以添加多少个修饰符来封装此类?()
第9题:
类Student代码如下:D class Student{ String name; int age; Student(String nm){ (构造方法) name = nm; } } 执行语句Student stu = new Student()后,字段age的值是哪项?()
第10题:
Given: 11.String test = "This is a test"; 12.String[] tokens = test.split("/s"); 13.System.out.println(tokens.length); What is the result?()
第11题:
2
3
4
5
第12题:
第13题:
下列语句能给数组赋值而不使用for循环的是
A.myArray{[1]="One";[2]="Two";[3]="Three";}
B.String s[5]=new String[]{"Zero", "One", "Two", "There", "Four"};
C.String s[]=new String[]{"Zero", "One", "Two", "There", "Four"};
D.String s[]=new String[]=|"Zero", "One", "Two", "There", "Four"};
第14题:
String s = new String("xyz");创建了几个String Object?
二者之间有什么区别?
两个,一个放在常量区,不管写多少遍,都是同一个。New String 每写一遍,就创建一个新。
第15题:
下列语句能给数组赋值,而不使用for循环的是
A.myArray{[1]="One";[2]="Two";[3]="Three";}
B.String s[5]=new String[] {"Zero","One","Two","Three","Four"};
C.String s[]=new String[] {"Zero","One","Two","Three","Four"};
D.String s[]=new String[]= {"Zero","One","Two","Three","Four"};
第16题:
哪个语句创建了一个数组实例?()
第17题:
下面哪些语句能够正确地生成5个空字符串?()
第18题:
下列语句创建了多少个string对象?() string[,]strArray=new string[3][4];
第19题:
String s=new String("xyz");创建了几个String Object?
第20题:
11. String test = “This is a test”; 12. String[] tokens = test.split(”/s”); 13. System.out.println(tokens.length); What is the result?()
第21题:
import java.util.*; public class WrappedString { private String s; public WrappedString(String s) { this.s = s; } public static void main(String[] args) { HashSet
第22题:
0
1
2
3
4
Compilation fails.
An exception is thrown at runtime.
第23题:
0
3
4
12
第24题:
int a1[]={3,4,5};
String a2[]={string1,string1,string1};
String a3[]=new String(3);
int[][] a4=new int[3][3];