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

c++ ##_##

1) What is the correct way to access each element of an array without using an index variable?
  1. Using do-while loop

  2. Using for loop

  3. Using while loop

  4. Using a foreach loop

Answer & Explanation

Correct answer: 4
Using a for each loop

In C#.NET, using a foreach loop, we can access each element of an array without using the index variable.

1)在不使用索引变量的情况下访问数组每个元素的正确方法是什么?
  1. 使用do-while循环

  2. 使用for循环

  3. 使用while循环

  4. 使用foreach循环

答案与解释

正确答案:4
为每个循环使用

在C#.NET中,使用foreach循环,我们无需使用index变量即可访问数组的每个元素。

2) There are the following options are given below, which of them are the correct way to initialize an array of three integers?
  1. int []arr;
    arr = new int[3];
    arr[0]=1;
    arr[1]=1;
    arr[2]=1;
    
    
  2. int []arr;
    arr = new int {1,2,3};
    
    

Options:

  1. Only A

  2. Only B

  3. Only D

  4. A, B, D

Answer & Explanation

Correct answer: 4
A, B, D

A, B and D are the correct ways to initialize an array of an integer with 3 elements.

2)下面给出了以下选项,其中哪个是初始化三个整数的数组的正确方法?
  1.  int [ ] arr ;
    arr = new int [ 3 ] ;
    arr [ 0 ] = 1 ;
    arr [ 1 ] = 1 ;
    arr [ 2 ] = 1 ;
    
    
  2.  int [ ] arr ;
    arr = new int { 1 , 2 , 3 } ;
    
    

选项:

  1. 只有一个

  2. 只有B

  3. 只有D

  4. A,B,D

答案与解释

正确答案:4
A,B,D

A,B和D是初始化具有3个元素的整数数组的正确方法。

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

	foreach (int X in ARR)
	{
		Console.Write(X + " ");
	}
}

  1. 1 2 3 4 5

  2. 0 0 0 0 0

  3. Syntax Error

  4. Runtime Exception

Answer & Explanation

Correct answer: 1
1 2 3 4 5

The above code will print "1 2 3 4 5" on console screen.

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

  2. 0 0 0 0 0

  3. 语法错误

  4. 运行时异常

答案与解释

正确答案:1
1 2 3 4 5

上面的代码将在控制台屏幕上显示“ 1 2 3 4 5”

4) If we created an array of 5 integers, can we increase array size from 5 to 10?
  1. Yes

  2. No

Answer & Explanation

Correct answer: 1
Yes

Yes, we can increase the size of the already created array.

4)如果我们创建了一个由5个整数组成的数组,是否可以将数组大小从5增加到10?
  1. 没有

答案与解释

正确答案:1

是的 ,我们可以增加已经创建的数组的大小。

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

	ARR = new int[4];

	foreach (int X in ARR)
	{
		Console.Write(X + " ");
	}
}

  1. 1 2 0 0

  2. 0 0 0 0

  3. Syntax Error

  4. Runtime Error

Answer & Explanation

Correct answer: 2
0 0 0 0

The above code will print "0 0 0 0" on console screen.

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

  2. 0 0 0 0

  3. 语法错误

  4. 运行时错误

答案与解释

正确答案:2
0 0 0 0

上面的代码将在控制台屏幕上显示“ 0 0 0 0”

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

c++ ##_##

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值