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

c++ ##_##

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

	Console.WriteLine(ARR.GetLength(1));
}

  1. 5

  2. 6

  3. Syntax Error

  4. Runtime Error

Answer & Explanation

Correct answer: 4
Runtime Error

The above code will generate runtime exception.

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

  2. 6

  3. 语法错误

  4. 运行时错误

答案与解释

正确答案:4
运行时错误

上面的代码将生成运行时异常。

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

	Console.WriteLine(ARR.GetLength(0));
}

  1. 5

  2. 6

  3. Syntax Error

  4. Runtime Error

Answer & Explanation

Correct answer: 1
5

The above code will print length of created array.

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

  2. 6

  3. 语法错误

  4. 运行时错误

答案与解释

正确答案:1
5

上面的代码将打印创建的数组的长度。

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

	Console.WriteLine(ARR.MAX());
}

  1. 5

  2. 6

  3. Syntax Error

  4. Runtime Error

Answer & Explanation

Correct answer: 3
Syntax Error

The above code will generate syntax error, because MAX() method is not available.

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

  2. 6

  3. 语法错误

  4. 运行时错误

答案与解释

正确答案:3
语法错误

上面的代码将生成语法错误,因为MAX()方法不可用。

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

	int X = 0;
	int i = 0;

	X = ARR[0];
	for (i = 1; i < ARR.Length; i++)
	{
		if (X < ARR[i])
			X = ARR[i];
	}

	Console.WriteLine(X);
}

  1. 5

  2. 6

  3. Syntax Error

  4. Runtime Error

Answer & Explanation

Correct answer: 1
5

The above code will print greatest value of array.

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

  2. 6

  3. 语法错误

  4. 运行时错误

答案与解释

正确答案:1
5

上面的代码将打印数组的最大值。

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

	Console.WriteLine(ARR.GetLength(1));
}

  1. 5

  2. 2

  3. Syntax Error

  4. Runtime Error

Answer & Explanation

Correct answer: 2
2

The GetLength(1) method will print specified number of elements in the dimensions.

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

  2. 2

  3. 语法错误

  4. 运行时错误

答案与解释

正确答案:2
2

GetLength(1)方法将在维中打印指定数量的元素。

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

c++ ##_##

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值