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

Show Answer
Share Facebook gmail Twitter
2
When the static constructor of an instance class  is called?
  1. Before the each instance of the class created.
  2. After the each instance of the class created.
  3. Before the first instance of the class created.
  4. After the first instance of the class created.
Show Answer
Share Facebook gmail Twitter
3
Which of the below given keywords are not supported inside a static method?
1.this  2.base 3.yield 4.continue
  1. Keywords 1&2 are not supported.
  2. Keywords 1&3 are not supported.
  3. All keywords are supported.
  4. All the given keywords are not supported.
Show Answer
Share Facebook gmail Twitter
4
Which of the following statement is true about  static constructors in static class?
  1. We can not write static constructors for static class
  2. We can write parameterized constructors for static class
  3. We can create more than one constructor in a static class
  4. We can't give accessmodifiers for static constuctors
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
6
When to create a static class in the programming?
  1. When a class is having only static members .
  2. While creating utility classes which are too frequently accessed from all over the program.
  3. When there is no necessity of creating object of a given class.
  4. All the options are correct.
Show Answer
Share Facebook gmail Twitter
7
Which of the following C# elements are not allowed to be declared as static ?
1.Class
2.Enum
3.Struct
4.Delegate
  1. All the elements are not allowed to be declared as static.
  2. Only a struct and enum.
  3. Only enum and delegate.
  4. Except class all the elements are not allowed.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
9
Which of the following statement is not true about static keyword?
  1. We can declare datamember or field as static.
  2. We can declare a local variable as static.
  3. We can declare a class as static
  4. We can not declare an inner class as static.
Show Answer
Share Facebook gmail Twitter
10
What is the output of the following code?
public class A
{
    public int x = 20;
    public static int M()
    {
        A a = new A();
        return a.x;
    }
}
  1. Compilation error since we can not  create an object of class A in static method M.
  2. Runtime error.
  3. Method M() will return 20 as output when it is called.
  4. Compilation error since we can not access instance member x from static method M.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
12
Which of the following statement should be added to the method Display( )  to get output 90,93?
class A
{
    protected int x = 93;
}
class B: A
{
    int x = 90; 
    public void Display()
    {
    } 
}
  1. Console.WriteLine(x + " ," + this.x);
  2. Console.WriteLine(base.x+ " ," + x);
  3. Console.WriteLine(x+ " ," + base.x);
  4. Console.WriteLine(this.x + " ," + x);
Show Answer
Share Facebook gmail Twitter
13
Assume that class ABC is inherited from class XYZ. Which of the following statement is true about construction of an object of class ABC?
  1. The constructor of class ABC only will be called.
  2. The constructor of class XYZ only will be called.
  3. While creating the object firstly the constructor of class ABC will be called followed by constructor of class XYZ.
  4. While creating the object firstly the constructor of class XYZ will be called followed by constructor of class ABC
Show Answer
Share Facebook gmail Twitter
14
Which of the following statement is false about Inheritance in C#.NET?
  1. A derived class may not be able to access all the base class data.
  2. Inheritance cannot suppress the base class functionality.
  3. Inheritance can extend the base class functionality.
  4. In inheritance chain construction of object happens from base towards derived.
Show Answer
Share Facebook gmail Twitter
15
How can you prevent inheritance from a class(not a inner class) in C#.NET ?
  1. Declare the class as private.
  2. Declare the class as sealed.
  3. Declare the class as abstract.
  4. None of the above
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
18
How to access the base class members( which are supressed in derived class) from the derived class?
  1. By using this key word
  2. By using  base keyword
  3. Directly we can access
  4. We can not access
Show Answer
Share Facebook gmail Twitter
19
Which of the below given option are true about the following code?
public class A
{
    public int x = 20;
}
public class B:A
{
    public int x = 30;
}
  1. C# compiler throws an error.
  2. C# compiler throws a compilation warning.
  3. CLR will throw an Exception when the object of B class is created.
  4. None of the options are correct.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :