C# Programming - Classes and Objects - Discussion
Discussion Forum : Classes and Objects - General Questions (Q.No. 15)
15.
Which of the following statements are correct about the C#.NET code snippet given below?
namespace IndiabixConsoleApplication
{
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);
}
}
}Discussion:
4 comments Page 1 of 1.
Ibm said:
3 years ago
Hi All.
SetData Creates a compiler error because this.j = jj is missing the `;`.
SetData Creates a compiler error because this.j = jj is missing the `;`.
Avinash said:
8 years ago
whenever we calling to method setdata repetadely it modifying class level variable inside method[
[( this.i ) and (this.j)] every time .
Hence answer is 5.
[( this.i ) and (this.j)] every time .
Hence answer is 5.
Yakesh said:
1 decade ago
Just write the statement
Console.WriteLine(i+" "+j);
Will get the o/p:
10 2
5 10
Hence option 5 is correct
Console.WriteLine(i+" "+j);
Will get the o/p:
10 2
5 10
Hence option 5 is correct
Michael said:
1 decade ago
That answer is kind of misleading actually. It doesn't adequately describe the nature of the condition. Different how? During each call to SetData()? Logically, this answer doesn't necessarily follow, except by way of elimination of the other (obviously) false answers.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers