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# interview questions and answers

1
what is the use of using statement in c# ?
  1. Using statement used for deleting managed objects.
  2. Using statement used for calling dispose method of Idisposable interface properly by using try and finally pattern.
  3. Using statement is used as a replacement to the C#'s finalize method.
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
2
How to call dispose method in C# ?
  1. Use try and finally pattern for calling dispose method.
  2. Use using statement to wrap an object which is using unmanaged resources to call its dispose method automatically.
  3. It is always better to call dispose method in destructors.
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
3
identify the execution sequence or order of destructors for the following sample code ?
public class Test
{
    public static void Main(string[] args)
    {
        B b = new B();
    }
}
public class A
{
    ~A()
    {
        Console.WriteLine("Killing A");
    }
}
public class B : A
{
    ~B()
    {
        Console.WriteLine("Killing B");
    }
}
  1. Only derived class destructor is executed.
  2. Only base class destructor is executed.
  3. First base class destructor is executed and then derived class destructor is executed.
  4. First derived class destructor is executed then base class destructor is executed.
Show Answer
Share Facebook gmail Twitter
4
What is the use of SuppressFinalize method of garbage collector class ?
  1. suppressfinalize method stops garbage collector acting upon an object which is passed to it.
  2. suppressfinalize method stops garbage collector from calling a destructor of an object which is passed to it.
  3. suppressFinalize method used for calling garbage collector explicitly.
  4. Statements 1 and 2 are correct.
Show Answer
Share Facebook gmail Twitter
5
What is the use of f-reachable queue ?
  1. f-reachable queue contains all the the class objects which are having destructors associated .
  2. Garbage collector will not delete the objects which are having references in f-reachable queue.
  3.  Statements 1 and 2 are correct.
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
6
what is the use of finalization queue ?
  1. Garbage Collector removes all the objects which are having references in finalization queue by calling finalize methods on those objects.
  2. Garbage Collector will not delete the objects which are having references in finalization queue.
  3. Garbage Collector uses the finalization queue to identify the classes which are implementing Idisposable interface.
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
7
How Garbage Collection works in C# ( identify the correct step by step procedure ) ?
  1. 1.GC is usually activated by CLR when it identifies scarcity of memory for executing remaining program .
    2.When GC is activated it consults register CPU's , stack memory variables and also checks for objects address present in f-reachable queue. 
    3.Removes all objects which are not having references .
  2. 1.GC must be activated programmatically .
    2.When GC is activated it  directly checks managed and unmanaged heap , identifies un used objects.
    3.Removes all un used objects .
  3. 1.GC can be activated by CLR or programmatically.
    2.When GC is activated it checks only managed heap memory and deletes all objects which are not having corresponding local variables in stack memory . 
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
8
How Garbage Collector identifies dead objects ?
  1. By reading references from CPU registers also by reading data from locals or stack memory variables.
  2. By looking at data present in unmanaged heap.
  3. By looking at the data present Managed heap memory .
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
9
How to check number of times garbage collection has occurred in a Generation?
  1. use GC.CollectionCount(generationNumber)
  2. No way to check number garbage collections
  3. use GC.Collect() method
  4. Use GC.GetGeneration()
Show Answer
Share Facebook gmail Twitter
10
How to check the presence of particular object in a Generation?
  1. use GC.Generation(objectreference)
  2. use GC.GetGeneration(objectreference)
  3. use GC.Collect() method .
  4. use GC.GetGenerationNumber() .
Show Answer
Share Facebook gmail Twitter
Read more papers :