adplus-dvertising
frame-decoration

Question

Which of the following statements are correct about the C#.NET code snippet given below?

namespace CompSciBitsConsoleApplication
{ 
    class Sample
    { 
        int i, j; 
        public void SetData(int ii, int jj)
        {
            this.i = ii;
            this.j = jj 
        } 
    } 
    class MyProgram
    { 
        static void Main(string[ ] args)
        { 
            Sample s1 = new Sample(); 
            s1.SetData(10, 2); 
            Sample s2 = new Sample(); 
            s2.SetData(5, 10); 
        } 
    } 
}

a.

The code will not compile since we cannot explicitly use this.

b.

Using this in this program is necessary to properly set the values in the object.

c.

The call to SetData() is wrong since we have not explicitly passed the this reference to it.

d.

Contents of this will be different during each call to SetData().

Answer: (d).Contents of this will be different during each call to SetData().

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which of the following statements are correct about the C#.NET code snippet given below?

Similar Questions

Discover Related MCQs

Q. Which of the following statements is correct about classes and objects in C#.NET?

Q. Which of the following is used to define the member of a class externally?

Q. The operator used to access member function of a class?

Q. What is the most specified using class declaration ?

Q. Which of following statements about objects in “C#” is correct?

Q. “A mechanism that binds together code and data in manipulates, and keeps both safe from outside interference and misuse.In short it isolates a particular code and data from all other codes and data. A well-defined interface controls the access to that particular code and data.”

Q. Correct way of declaration of object of the following class is ?

class name

Q. The data members of a class by default are ?

Q. What does the following code imply ?

csharp abc;
abc = new charp();

Q. Which refrence modifier is used to define reference variable?

Q. Select the wrong statement about ‘ref’ keyword in C#?

Q. Select correct differences between ‘=’ and ‘==’ in C#.

Q. What is output for the following set of expression?

int a+= (float) b/= (long)c

Q. Which of following statements are correct about functions?

Q. When a function fun() is to receive an int, a single & a double and it is to return a decimal, then the correct way of defining this function is?

Q. How many values does a function return?

Q. Which return statement correctly returns the output:

Q. Number of constructors a class can define is ?

Q. Correct statement about constructors in C#.NET is ?

Q. Which among the following is the correct statement :
Constructors are used to