Online C# Programming Test - C# Programming Test - Random

Instruction:

  • This is a FREE online test. Beware of scammers who ask for money to attend this test.
  • Total number of questions: 20.
  • Time allotted: 30 minutes.
  • Each question carries 1 mark; there are no negative marks.
  • DO NOT refresh the page.
  • All the best!

Marks : 2/20


Total number of questions
20
Number of answered questions
0
Number of unanswered questions
20
Test Review : View answers and explanation for this test.

1.
Which of the following constitutes the .NET Framework?
  1. ASP.NET Applications
  2. CLR
  3. Framework Class Library
  4. WinForm Applications
  5. Windows Services
1, 2
2, 3
3, 4
2, 5
Your Answer: Option
(Not Answered)
Correct Answer: Option

2.
Which of the following are valid .NET CLR JIT performance counters?
  1. Total memory used for JIT compilation
  2. Average memory used for JIT compilation
  3. Number of methods that failed to compile with the standard JIT
  4. Percentage of processor time spent performing JIT compilation
  5. Percentage of memory currently dedicated for JIT compilation
1, 5
3, 4
1, 2
4, 5
Your Answer: Option
(Not Answered)
Correct Answer: Option

3.

Which of the following statement correctly assigns a value 33 to a variable c?

byte a = 11, b = 22, c;
c = (byte) (a + b);
c = (byte) a + (byte) b;
c = (int) a + (int) b;
c = (int)(a + b);
c = a + b;
Your Answer: Option
(Not Answered)
Correct Answer: Option

4.
What will be the output of the following code snippet when it is executed?
    int x = 1; 
    float y = 1.1f;
    short z = 1;
    Console.WriteLine((float) x + y * z - (x += (short) y));
0.1
1.0
1.1
11
Your Answer: Option
(Not Answered)
Correct Answer: Option

5.
Which of the following statements are correct?
  1. We can assign values of any type to variables of type object.
  2. When a variable of a value type is converted to object, it is said to be unboxed.
  3. When a variable of type object is converted to a value type, it is said to be boxed.
  4. Boolean variable cannot have a value of null.
  5. When a value type is boxed, an entirely new object must be allocated and constructed.
2, 5
1, 5
3, 4
2, 3
Your Answer: Option
(Not Answered)
Correct Answer: Option

6.
What will be the output of the C#.NET code snippet given below?
char ch = Convert.ToChar ('a' | 'b' | 'c'); 
switch (ch)
{
    case 'A': 
    case 'a':
    Console.WriteLine ("case A | case a");
    break;
    
    case 'B': 
    case 'b':
    Console.WriteLine ("case B | case b");
    break;
    
    case 'C':
    case 'c':
    case 'D':
    case 'd':
    Console.WriteLine ("case D | case d");
    break;
}
case A | case a
case B | case b
case D | case d
Compile Error
No output
Your Answer: Option
(Not Answered)
Correct Answer: Option

7.
What will be the output of the code snippet given below?
int i;
for(i = 0; i<=10; i++)
{
    if(i == 4)
    {
        Console.Write(i + " "); continue;
    }
    else if (i != 4)
        Console.Write(i + " "); else
    break;
}
1 2 3 4 5 6 7 8 9 10
1 2 3 4
0 1 2 3 4 5 6 7 8 9 10
4 5 6 7 8 9 10
4
Your Answer: Option
(Not Answered)
Correct Answer: Option

8.
Which of the following statements are correct about functions and subroutines used in C#.NET?
  1. A function cannot be called from a subroutine.
  2. The ref keyword causes arguments to be passed by reference.
  3. While using ref keyword any changes made to the parameter in the method will be reflected in that variable when control passes back to the calling method.
  4. A subroutine cannot be called from a function.
  5. Functions and subroutines can be called recursively.
1, 2, 4
2, 3, 5
3, 5
4, 5
None of these
Your Answer: Option
(Not Answered)
Correct Answer: Option

9.
Which of the following statements are correct about the this reference?
  1. this reference can be modified in the instance member function of a class.
  2. Static functions of a class never receive the this reference.
  3. Instance member functions of a class always receive a this reference.
  4. this reference continues to exist even after control returns from an instance member function.
  5. While calling an instance member function we are not required to pass the this reference explicitly.
1, 4
2, 3, 5
3, 4
2, 5
None of these
Your Answer: Option
(Not Answered)
Correct Answer: Option

10.
Which of the following statements is correct?
A constructor can be used to set default values and limit instantiation.
C# provides a copy constructor.
Destructors are used with classes as well as structures.
A class can have more than one destructor.
Your Answer: Option
(Not Answered)
Correct Answer: Option

11.
Which of the following is the correct output of the C#.NET code snippet given below?
    int[][] a = new int[2][];
    a[0] = new int[4]{6, 1, 4, 3};
    a[1] = new int[3]{9, 2, 7}; 
    Console.WriteLine(a[1].GetUpperBound(0));
3
4
7
9
2
Your Answer: Option
(Not Answered)
Correct Answer: Option

12.
A class D can be derived from a class C, which is derived from a class B, which is derived from a class A.
True
False
Your Answer: Option
(Not Answered)
Correct Answer: Option
Explanation:
This is known as multiple levels of inheritance.

13.
Which of the following statements about a String is correct?
A String is created on the stack.
Whether a String is created on the stack or the heap depends on the length of the String.
A String is a primitive.
A String can be created by using the statement String s1 = new String;
A String is created on the heap.
Your Answer: Option
(Not Answered)
Correct Answer: Option

14.
Which of the following will be the correct output for the C#.NET program given below?
namespace IndiabixConsoleApplication
{ 
    struct Sample
    { 
        public int i;
    }
    class MyProgram
    { 
        static void Main(string[] args)
        {
            Sample x = new Sample(); 
            x.i = 10; 
            fun(ref x); 
            Console.Write(x.i + " ");
        }
        public static void fun(ref Sample y)
        { 
            y.i = 20;
            Console.Write(y.i + " "); 
        } 
    } 
}
20 10
10 20
10 10
20 20
None of the above
Your Answer: Option
(Not Answered)
Correct Answer: Option

15.
Which of the following statements are correct about the delegate declaration given below?
    delegate void del(int i);
  1. On declaring the delegate a class called del will get created.
  2. The signature of del need not be same as the signature of the method that we intend to call using it.
  3. The del class will be derived from the MulticastDelegate class.
  4. The method that can be called using del should not be a static method.
  5. The del class will contain a one-argument constructor and an lnvoke() method.
1, 2 and 3 only
1, 3 and 5 only
2 and 4 only
4 only
All of the above
Your Answer: Option
(Not Answered)
Correct Answer: Option

16.
Which of the following is the correct output for the C#.NET code snippet given below?
enum color
{
    red,
    green,
    blue 
}
color c = color.red;
Type t;
t = c.GetType();
string[ ]str;
str = Enum.GetNames(t);
Console.WriteLine(str[ 0 ]);
red
0
1
-1
color.red
Your Answer: Option
(Not Answered)
Correct Answer: Option

17.
How many enumerators will exist if four threads are simultaneously working on an ArrayList object?
1
3
2
4
Depends upon the Project Setting made in Visual Studio.NET.
Your Answer: Option
(Not Answered)
Correct Answer: Option

18.
Which of the following is the correct way to access all elements of the Queue collection created using the C#.NET code snippet given below?
Queue q = new Queue(); 
q.Enqueue("Sachin"); 
q.Enqueue('A'); 
q.Enqueue(false); 
q.Enqueue(38); 
q.Enqueue(5.4);
IEnumerator e;
e = q.GetEnumerator(); 
while (e.MoveNext())
Console.WriteLine(e.Current);
IEnumerable e;
e = q.GetEnumerator(); 
while (e.MoveNext()) 
Console.WriteLine(e.Current);
IEnumerator e;
e = q.GetEnumerable(); 
while (e.MoveNext()) 
Console.WriteLine(e.Current);
IEnumerator e;
e = Queue.GetEnumerator(); 
while (e.MoveNext()) 
Console.WriteLine(e.Current);
Your Answer: Option
(Not Answered)
Correct Answer: Option

19.
Which of the following statements are correct about exception handling in C#.NET?
  1. try blocks cannot be nested.
  2. In one function, there can be only one try block.
  3. An exception must be caught in the same function in which it is thrown.
  4. All values set up in the exception object are available in the catch block.
  5. While throwing a user-defined exception multiple values can be set in the exception, object.
1 only
1 and 2 only
3 only
4 and 5 only
All of the above
Your Answer: Option
(Not Answered)
Correct Answer: Option

20.
Which of the following statements are correct about exception handling in C#.NET?
  1. If an exception occurs then the program terminates abruptly without getting any chance to recover from the exception.
  2. No matter whether an exception occurs or not, the statements in the finally clause (if present) will get executed.
  3. A program can contain multiple finally clauses.
  4. A finally clause is written outside the try block.
  5. finally clause is used to perform clean up operations like closing the network/database connections.
1 only
2 only
2 and 5 only
3 and 4 only
None of the above
Your Answer: Option
(Not Answered)
Correct Answer: Option

*** END OF THE TEST ***
Time Left: 00:29:56
Post your test result / feedback here: