C# Programming - Classes and Objects - Discussion
Discussion Forum : Classes and Objects - General Questions (Q.No. 13)
13.
Which of the following will be the correct output for the C#.NET program given below?
namespace IndiabixConsoleApplication
{
class Sample
{
int i;
Single j;
public void SetData(int i, Single j)
{
this.i = i;
this.j = j;
}
public void Display()
{
Console.WriteLine(i + " " + j);
}
}
class MyProgram
{
static void Main(string[ ] args)
{
Sample s1 = new Sample();
s1.SetData(36, 5.4f);
s1.Display();
}
}
}
Discussion:
9 comments Page 1 of 1.
Kirti Sharma said:
2 years ago
Here, this keyword holds the current value that's why the answer is 36 5.4
if "this" keyword is removed then o/p will be 0 0.
if "this" keyword is removed then o/p will be 0 0.
Priti said:
8 years ago
B is the correct answer because this keyword holds the current value of the object.
Gman said:
9 years ago
According to me, Only D is the correct Answer.
Katia said:
1 decade ago
Why B and not C?
Shobhit said:
1 decade ago
Ohh yes without using this output will 00.
Shobhit said:
1 decade ago
Without using this the output also be same 36 5.4.
Shiva said:
1 decade ago
0 0 will be the output if we don't use this keyword.
Kritika saxena said:
1 decade ago
How this answer comes,
And we don't use this.i = i;
And simply we write i = i; then what will be the output?
And we don't use this.i = i;
And simply we write i = i; then what will be the output?
Asto said:
1 decade ago
public void SetData(int i, Single j)
{
this.i = i;
this.j = j;
}
in this method they are using this keyword
{
this.i = i;
this.j = j;
}
in this method they are using this keyword
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers