c# 类对象和实例对象_C#类和对象能力问题 套装2

c# 类对象和实例对象

1) There are following statements are given below, which of them are correct in about "this" reference in C#.NET?
  1. A static method of a class can never receive the "this" reference.

  2. We can modify "this" reference in the instance method of a class.

  3. When we are calling an instance method of a class, it is not required to pass "this" reference explicitly.

  4. An instance method of a class is always receiving the "this" reference.

Options:

  1. Only A

  2. Only B

  3. Only C

  4. A, C and D

Answer & Explanation

Correct answer: 4
A, C and D

In the given statements, A, C and D are correct statements.

1)下面给出了以下语句,其中哪些对于C#.NET中的“ this”引用是正确的?
  1. 类的静态方法永远不会收到“ this”引用。

  2. 我们可以在类的实例方法中修改“ this”引用。

  3. 当我们调用类的实例方法时,不需要显式传递“ this”引用。

  4. 类的实例方法始终接收“ this”引用。

选项:

  1. 只有一个

  2. 只有B

  3. 只有C

  4. A,C和D

答案与解释

正确答案:4
A,C和D

在给定的语句中,A,C和D是正确的语句。

2) There are following statements are given below, which of them are correct in about objects of a user-defined class is known as "MyClass"?
  1. All Objects of "MyClass" may have the same or different data members.

  2. All Objects of "MyClass" have the same data members.

  3. All Objects of "MyClass" will share the same copy of methods.

  4. Objects of "MyClass" will have the same or different data members depends upon the project setting in Visual Studio.

Options:

  1. Only A

  2. Only B

  3. C and D

  4. B and C

Answer & Explanation

Correct answer: 4
B and C

In the given statements, B and C are correct statements.

2)下面给出了以下语句,其中哪些关于用户定义类的对象“ MyClass”是正确的?
  1. “ MyClass”的所有对象可能具有相同或不同的数据成员。

  2. “ MyClass”的所有对象都具有相同的数据成员。

  3. “ MyClass”的所有对象将共享相同的方法副本。

  4. “ MyClass”的对象将具有相同或不同的数据成员,具体取决于Visual Studio中的项目设置。

选项:

  1. 只有一个

  2. 只有B

  3. C和D

  4. B和C

答案与解释

正确答案:4
B和C

在给定的语句中,B和C是正确的语句。

3) What are the correct statements about given code snippets?
    Test T = new Test();

  1. Here we creating object "Test".

  2. Here we are creating an object of class "Test".

  3. Here we are creating an object of class "Test" on the stack.

  4. Here we are creating reference "T" on the stack and object of the type "Test" on the heap.

Options:

  1. Only A

  2. Only B

  3. Only C

  4. B and D

Answer & Explanation

Correct answer: 4
B and D

In the given statements, B and D are correct statements.

3)关于给定代码段的正确陈述是什么?
  1. 在这里,我们创建对象“ Test”。

  2. 在这里,我们正在创建“测试”类的对象。

  3. 在这里,我们在堆栈上创建一个“ Test”类的对象。

  4. 在这里,我们在堆栈上创建引用“ T”,并在堆上创建类型为“ Test”的对象。

选项:

  1. 只有一个

  2. 只有B

  3. 只有C

  4. B和D

答案与解释

正确答案:4
B和D

在给定的语句中,B和D是正确的语句。

4) What are the correct statements about given code snippets?
    Test T1 = new Test();
    Test T2 = new Test();

  1. The value of T1 and T2 will be same exactly.

  2. Here we create two objects of Test class in the stack.

  3. The two objects of a class that will always create in adjacent memory locations.

  4. Here we create two objects of Test class.

Options:

  1. Only A

  2. Only B

  3. Only C

  4. Only D

Answer & Explanation

Correct answer: 4
Only D

In the given statements, only D is a correct statement.

4)关于给定代码段的正确陈述是什么?
  1. T1和T2的值将完全相同。

  2. 在这里,我们在堆栈中创建Test类的两个对象。

  3. 一个类的两个对象将始终在相邻的内存位置中创建。

  4. 在这里,我们创建两个Test类的对象。

选项:

  1. 只有一个

  2. 只有B

  3. 只有C

  4. 只有D

答案与解释

正确答案:4
只有D

在给定的语句中,只有D是正确的语句。

5) What is the correct output of given code snippets?
using System;

public class Sample
{
    static public void Main()
    {
        int A = 0;
        int B = new int();
        string S1 = "";
        string S2 = "";

        A = 123;
        B = 456;

        S1 = A.ToString();
        S2 = B.ToString();

        Console.WriteLine(S1+", "+S2);
    }
}

  1. 123, 456

  2. @123, @456

  3. Syntax Error

  4. Runtime Exception

Answer & Explanation

Correct answer: 1
123, 456

The above will print (123, 456) on the console screen.

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

  2. @ 123,@ 456

  3. 语法错误

  4. 运行时异常

答案与解释

正确答案:1
123、456

以上内容将在控制台屏幕上打印(123,456)。

翻译自: https://www.includehelp.com/dot-net/csharp-class-object-aptitude-questions-and-answers-2.aspx

c# 类对象和实例对象

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值