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

1
Which of the below given methods should be present in base class for declaring a override method in derived class ?
  1. A virtual method.
  2. An abstract method.
  3. Either a virtual or abstract or override method.
  4. A sealed method.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
4
What is the use of  new keyword in csharp ?
  1. new keyword used for creating an object of a class.
  2. new keyword is used for hiding base class members in derived class without producing compilation warning.
  3. Options 1 & 2 are correct.
  4. new keyword used for accessing base class members from derived classes.
Show Answer
Share Facebook gmail Twitter
5
What is the use of a default constructor?
  1. It is used for creating the object.
  2. It is used for initializing fields of a class with default values.
  3. A default constructor used for intializing all the values fields with 0's and all the reference fields with null values.
  4. None of the above
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
7
What is the main difference between a deep copy and shallow copy?
  1. A deep copy of a collection copies only the elements of collection
  2. A shallow copy of a collection copies only the elements of the collection
  3. A shallow copies the elements and everything directly or indirectly referenced by the elements.
  4. None of the above
Show Answer
Share Facebook gmail Twitter
8
Which of the below given syntax is correct for displaying parent class x variable data when the derived class object is created ?
public class A { public int  x=20 ; }
public class B:A { public int x=30 ; }
  1. B b=new B();
    Console.WriteLine(b.x);
  2. B b=new A();
    Console.WriteLine(b.x);
  3. A a=new B();
    Console.WriteLine(a.x);
  4. It is not possible to print data present in class A's x variable .
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
10
What is the use of  is and as keywords ?
  1. 1. is keyword useful for type checking ( identifying a variables data type ) .
    2. as keyword useful for converting one type into another type .
  2. 1. is keyword useful for converting one type into another type .
    2. as keyword useful for type checking ( identifying a variables data type ) .
  3. 1. is keyword useful for converting a value type into another value type .
    2. as keyword useful for converting a reference type into another reference type.
  4. None of the above
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
13
What is a sealed class ?
  1. A sealed class is a type of class which cannot act as a child class.
  2. A sealed class is a class which cannot act as a parent/base class.
  3. A sealed class cannot act as a child class as well as parent class.
  4. A sealed class is a class which cannot contain override methods.
Show Answer
Share Facebook gmail Twitter
14
What is an abstract class ?
  1. An abstract class is a class which may contain zero or more abstract members.
  2. An abstract class is a class which can not contain parents.
  3. An abstract class is a class which cannot participate in inheritance.
  4. All the above.
Show Answer
Share Facebook gmail Twitter
15
Which of the following statements are correct about static functions?
  1. Static functions can access static data as well as instance data
  2. Static functions are outside the class scope.
  3. Static functions are invoked using class name.
  4. Static functions are invoked using objects of a class.
Show Answer
Share Facebook gmail Twitter
16
Which of the following statement is not true about static function?
  1. Static functions cannot call instance functions.
  2. Calling an instance function is faster than calling a static method.
  3. Static functions can access only static data.
  4. Instance functions can call static functions and access static data.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
18
What is a static class ?
  1. Class which is having only static members
  2. Class which is having instance or static member
  3. Class which is having atleast one static member and instance member
  4. We can not write static constructor for static class Explicitly
Show Answer
Share Facebook gmail Twitter
19
Which of the following statement is correct about following code?
public class A
{    public int x=10;
    public static int M(int x)
    {
       x = x + 1;
        return x;
    }
}
  1. The code will give Compilation error.
  2. The code will produce runtime error when the static method M is called.
  3. Static method M will return the value one more than the given value.
  4. None of the above.
Show Answer
Share Facebook gmail Twitter
20
What is the output of the below given code?
public class A
{
    Public static int x=10;
    public static int M()
    {
       this.x = this.x + 1;
        return this.x;
    }
}
  1. Compilation error.
  2. Runtime error.
  3. When the method M is called it will return 11.
  4. None of the options are correct.
Show Answer
Share Facebook gmail Twitter
Read more papers :