c++ ##_##_C#数组能力问题和解答 套装5

c++ ##_##

1) There are following options are given below, which is correct way to declare an array with 2 rows and 3 columns?
  1. int arr[2][3] = new int[2][3];

  2. int arr[2,3] = new int[2,3];

  3. int [2,3]arr = new int[2,3];

  4. int [2,3]arr = new [2,3]int;

Answer & Explanation

Correct answer: 3
int [2,3]arr = new int[2,3];

int [2,3]arr = new int[2,3]; - correct way to declare an array with 2 rows and 3 columns.

1)下面给出了以下选项,这是声明具有2行3列的数组的正确方法吗?
  1. int arr [2] [3] =新的int [2] [3];

  2. int arr [2,3] =新的int [2,3];

  3. int [2,3] arr = new int [2,3];

  4. int [2,3] arr = new [2,3] int;

答案与解释

正确答案:3
int [2,3] arr = new int [2,3];

int [2,3] arr = new int [2,3]; -声明具有2行3列的数组的正确方法。

2) Can we create 4-dimensional arrays in C#.NET?
  1. Yes

  2. No

Answer & Explanation

Correct answer: 1
Yes

Yes, we can create 4-dimensional arrays in C#.NET.

2)我们可以在C#.NET中创建4维数组吗?
  1. 没有

答案与解释

正确答案:1

是的 ,我们可以在C#.NET中创建4维数组。

3) What is the correct output of given code snippets?
static void Main(string[] args)
{
	int[, , ,] ARR = new int[2, 2, 2, 2];

	Console.WriteLine(ARR.Length);
}

  1. 8

  2. 16

  3. 32

  4. Syntax Error

Answer & Explanation

Correct answer: 2
16

The output of the above code will be 16 = (2 x 2 x 2 x 2 =16).

3)给定代码段的正确输出是什么?
  1. 8

  2. 16

  3. 32

  4. 语法错误

答案与解释

正确答案:2
16

上面代码的输出将是16 =(2 x 2 x 2 x 2 = 16)

4) What is the correct output of given code snippets?
static void Main(string[] args)
{
	string[] S = new string{ "XXXX", "YYYY" };

	Console.WriteLine(S[0] + " " + S[1]);
}

  1. XXXX YYYY

  2. Syntax Error

  3. xxxx yyyy

  4. Runtime Exception

Answer & Explanation

Correct answer: 2
Syntax Error

The above code will generate a syntax error because the declaration of an array of strings is not correct.

4)给定代码段的正确输出是什么?
  1. XXXX YYYY

  2. 语法错误

  3. xxxx yyyy

  4. 运行时异常

答案与解释

正确答案:2
语法错误

上面的代码将产生语法错误,因为字符串数组的声明不正确。

5) What is the correct output of given code snippets?
static void Main(string[] args)
{
	string[] S = new string[2]{ "XXXX", "YYYY" };

	Console.WriteLine(S[0] + " " + S[1]);
}

  1. XXXX YYYY

  2. Syntax Error

  3. xxxx yyyy

  4. Runtime Exception

Answer & Explanation

Correct answer: 1
XXXX YYYY

The above code will print "XXXX YYYY" on console screen.

5)给定代码段的正确输出是什么?
  1. XXXX YYYY

  2. 语法错误

  3. xxxx yyyy

  4. 运行时异常

答案与解释

正确答案:1
XXXX YYYY

上面的代码将在控制台屏幕上打印“ XXXX YYYY”

翻译自: https://www.includehelp.com/dot-net/csharp-arrays-aptitude-questions-and-answers-5.aspx

c++ ##_##

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值