Select chapter



Basics (2.papers)
Data Types (2.papers)
enums (2.papers)
OOPS (4.papers)
Arrays (1.papers)
Structs (2.papers)
Properties (2.papers)
Strings (2.papers)
Interfaces (1.papers)
Constructors (2.papers)
Ref-Out-Keywords (1.papers)
Collections (2.papers)
Generics (1.papers)
Hide

Sponsored Links


  

c# ref out keywords interview questions and answers

1
How to pass an argument by reference?
  1. By using ref keyword only.
  2. By using out keyword only.
  3. By using either ref or out keywords.
  4. We can pass directly without help of any keywords.
Show Answer
Share Facebook gmail Twitter
2
Which of the following statements is true about ref keyword ?
  1. An argument passed to a ref parameter must be initialized before passed to the method.
  2. To use ref parameter only the calling method must explicitly use ref keyword.
  3. To use ref parameter only the  method definition must explicitly use ref keyword.
  4. To use ref parameter either the method definition or the calling method must explicitly use ref keyword.
Show Answer
Share Facebook gmail Twitter
3
Which of the following statements is true about out keyword ?
  1. An argument passed to a out parameter must be initialized before passed to the method.
  2. An argument passed to a out parameter do not have to be initialized before passed to the method.
  3. To use out parameter either the method definition or the calling method must explicitly use ref keyword.
  4. Both second and third statements are valid.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
13
What is the output for the below given program ?
public class Test
{
    public static void Main();
    {       
        int y=10;
        M(out y);
        Console.WriteLine(y);

    }
    public void M(out int x)
    {
        x=90;
        x=x+90;
    }
}
  1. 90
  2. 180
  3. Compilation error, since out variable should not be initialized before being passed
  4. Compilation error , since out variable should not be initialized before being used
Show Answer
Share Facebook gmail Twitter
14
What is the output for the below given program ?
public class Test
{
    public static void Main();
    {       
        int y=10;
        M(out y);
        Console.Write(y);

    }
    public void M(out int x)
    {
        x=x+90;
    }
    }
}
  1. 100
  2. Compilation error, since out variable should not be initialized before being passed.
  3. Compilation error, since out variable should be initialized before usage in method.
  4. 2 and 3
Show Answer
Share Facebook gmail Twitter
15
Which of the following statement is true about ref and out keywords?
  1. ref and out keywords are different at runtime but they are treated as same at compile time.
  2. ref and out keywords are same at runtime and  at compile time.
  3. ref and out keywords are different at compile time but they are treated as same at runtime.
  4. ref and out keywords are different at runtime and  at compile time.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :