1. Which of the following is correct about params in C#
- By using the params keyword, a method parameter can be specified which takes a variable number of arguments or even no argument
- Additional parameters are not permitted after the params keyword in a method declaration
- Only one params keyword is allowed in a method declaration
- All of the above
2. If a is an array of 5 integers then which of the following is the correct way to increase its size to 10 elements
- int[] a = new int[5]; int[] a = new int[10];
- int[] a = int[5]; int[] a = int[10];
- int[] a = new int[5]; a.Length = 10;
- int[] a = new int[5]; a = new int[10];
3. Which of the following is the default access specifier of a class member variable
- Protected
- Private
- Public
- Internal
4. A derived class can stop virtual inheritance by declaring an override as
- Not inheritable
- Sealed
- Extends
- Inherits
5. What is indexer
- It allows an instance of a class to be indexed like an array
- It allows enumerator with class
- It creates index for instances of a class
- None of the above
6. Data type of a variable declared using var will be assigned at
- Runtime
- Application Initialization time
- CLR time
- Compile time
7. Assume class B is inherited from class A. Which of the following statements is correct about construction of an object of class B
class A { public A() { Console.WriteLine("A"); } }
class B : A { public B() { Console.WriteLine("B"); } }
B b = new B();
- While creating the object firstly the constructor of class B will be called followed by constructor of class A
- The constructor of only class B will be called
- While creating the object firstly the constructor of class A will be called followed by constructor of class B
- The order of calling constructors depends upon whether constructors in class A and class B are private or public
8. There are 1,000,000 key-value pairs in the dictionary. A pair with key X was added 10th in a row. For how many operations the dictionary will find and return a pair with the key X
- Will not find, due to the large number of elements in the dictionary
- For 10 operations
- Find only after exhaustive search
- In one operation
- Key search without knowing the value of a pair is not possible
9. Object A refers to object B, object B refers to object C, object C refers to object A. How the garbage collector works
- Will collect all the objects
- Will collect all objects only if links of type WeakReference
- Will not collect anyone each object has a link
10. What will be displayed in Console
void Main() {
var a = 3;
var b = 4;
Swap(a, b);
Console.WriteLine($"a = {a}, b = {b}");
}
void Swap(int x, int y) {
var temp = x;
x = y;
y = temp;
}
- a = 4, b = 3
- a = 3, b = 4
- a = 3, b = 3
- a = 4, b = 4
2 Комментарии
Good question)
ОтветитьУдалитьThanks
Удалить