Classes and Objects

Q1:
Which of the following statements are correct about the C#.NET code snippet given below?
namespace AptitudeCrackConsoleApplication
{ 
    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
The definition of SetData() is wrong since we have not explicitly collected the this reference.

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

ANS:E -

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

No answer description is available. Let's discuss.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.