AmbitionBox

Discover Best Places to work in India

C# Programming

C# Programming Questions and Answers

Showing 11 - 11 of 11 questions

11

Select the output for the following set of code :

class sample

{

     publicint i;

     publicint j;

     publicvoid fun(int i, int j)

     {

          this.i= i;

          this.j= j;

     }

}

class Program

{

     staticvoid Main(string[] args)

     {

          sample s =new sample();

          s.i=1;

          s.j=2;

          s.fun(s.i, s.j);

          Console.WriteLine(s.i+" "+ s.j);

          Console.ReadLine();

     }

}

 

 

 

 

 

 

 

a

Error while calling s.fun() due to inaccessible level

b

Error as ‘this’ reference would not be able to call ‘i’ and ‘j’

c

1 2

d

Runs successfully but prints nothing

correct answer c

Variable ‘i’ and ‘j’ declared with scope public in sample class are accessed using object of class ‘sample’ which is ‘s’.
Output:1 2.

Select a company to compare with

vs

Similar Companies