Online C# Programming Test - C# Programming Test 3



Loading...  Loading Test...

Instruction:

  • This is a FREE online test. DO NOT pay money to anyone to attend this test.
  • Total number of questions : 20.
  • Time alloted : 30 minutes.
  • Each question carry 1 mark, no negative marks.
  • DO NOT refresh the page.
  • All the best :-).


1.

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

A.
1, 5
B.
3, 4
C.
1, 2
D.
4, 5

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : .NET Framework

Discuss about this problem : Discuss in Forum


2.

Which of the following jobs are done by Common Language Runtime?

  1. It provides core services such as memory management, thread management, and remoting.
  2. It enforces strict type safety.
  3. It provides Code Access Security.
  4. It provides Garbage Collection Services.

A.
Only 1 and 2
B.
Only 3, 4
C.
Only 1, 3 and 4
D.
Only 2, 3 and 4
E.
All of the above

Your Answer: Option (Not Answered)

Correct Answer: Option E

Learn more problems on : .NET Framework

Discuss about this problem : Discuss in Forum


3.

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;
}

A.
case A | case a
B.
case B | case b
C.
case D | case d
D.
Compile Error
E.
No output

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Control Instructions

Discuss about this problem : Discuss in Forum


4.

Suppose n is a variable of the type Byte and we wish, to check whether its fourth bit (from right) is ON or OFF. Which of the following statements will do this correctly?

A.
if ((n&16) == 16)
Console.WriteLine("Fourth bit is ON");
B.
if ((n&8) == 8)
Console.WriteLine("Fourth bit is ON");
C.
if ((n ! 8) == 8)
Console.WriteLine("Fourth bit is ON");
D.
if ((n ^ 8) == 8)
Console.WriteLine("Fourth bit is ON");
E.
if ((n ~ 8) == 8)
Console. WriteLine("Fourth bit is ON");

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

byte myByte = 153; // In Binary = 10011001

byte n = 8; // In Binary = 00001000 
(Here 1 is the 4th bit from right)

Now perform logical AND operation (n & myByte)

 10011001
 00001000
---------
 00001000  Here result is other than 0, so evaluated to True.
---------

If the result is true, then we can understand that 4th bit is ON of the given data myByte.

Learn more problems on : Operators

Discuss about this problem : Discuss in Forum


5.

What will be the output of the C#.NET code snippet given below?

int num = 1, z = 5;

if (!(num <= 0))
    Console.WriteLine( ++num + z++ + " " + ++z ); 
else
    Console.WriteLine( --num + z-- + " " + --z ); 

A.
5 6
B.
6 5
C.
6 6
D.
7 7

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Operators

Discuss about this problem : Discuss in Forum


6.

What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            int i = 10;
            double d = 34.340;
            fun(i);
            fun(d);
        }
        static void fun(double d)
        {
            Console.WriteLine(d + " ");
        }
    }
}

A.
10.000000 34.340000
B.
10 34
C.
10 34.340
D.
10 34.34

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Functions and Subroutines

Discuss about this problem : Discuss in Forum


7.

What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            object[] o = new object[] {"1", 4.0, "India", 'B'};
            fun (o);
        }
        static void fun (params object[] obj)
        {
            for (int i = 0; i < obj.Length-1; i++)
            Console.Write(obj[i] + " ");
        }
    }
}

A.
1 4.0 India B
B.
1 4.0 India
C.
1 4 India
D.
1 India B

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Functions and Subroutines

Discuss about this problem : Discuss in Forum


8.

What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{ 
    class Sample
    { 
        static Sample()
        { 
            Console.Write("Sample class ");
        }
        public static void Bix1()
        { 
            Console.Write("Bix1 method ");
        } 
    } 
    class MyProgram
    { 
        static void Main(string[ ] args)
        { 
            Sample.Bix1();
        } 
    } 
}

A.
Sample class Bix1 method
B.
Bix1 method
C.
Sample class
D.
Bix1 method Sample class
E.
Sample class Sample class

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Constructors

Discuss about this problem : Discuss in Forum


9.

What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{ 
    class Baseclass
    { 
        public void fun()
        { 
            Console.Write("Base class" + " ");
        } 
    } 
    class Derived1: Baseclass
    { 
        new void fun()
        {
            Console.Write("Derived1 class" + " "); 
        } 
    } 
    class Derived2: Derived1
    { 
        new void fun()
        { 
            Console.Write("Derived2 class" + " ");
        }
    }
    class Program
    { 
        public static void Main(string[ ] args)
        { 
            Derived2 d = new Derived2(); 
            d.fun(); 
        } 
    } 
}

A.
Base class
B.
Derived1 class
C.
Derived2 class
D.
Base class Derived1 class
E.
Base class Derived1 class Derived2 class

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Inheritance

Discuss about this problem : Discuss in Forum


10.

Which one of the following statements is correct?

A.
Array elements can be of integer type only.
B.
The rank of an Array is the total number of elements it can contain.
C.
The length of an Array is the number of dimensions in the Array.
D.
The default value of numeric array elements is zero.
E.
The Array elements are guaranteed to be sorted.

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Arrays

Discuss about this problem : Discuss in Forum


11.

Which of the following are the correct ways to define an array of 2 rows and 3 columns?

  1. int[ , ] a;
    a = new int[2, 3]{{7, 1, 3},{2, 9, 6}};
  2. int[ , ] a;
    a = new int[2, 3]{};
  3. int[ , ] a = {{7, 1, 3}, {2, 9,6 }};
  4. int[ , ] a;
    a = new int[1, 2];
  5. int[ , ] a;
    a = new int[1, 2]{{7, 1, 3}, {2, 9, 6}};

A.
1, 2 , 3
B.
1, 3
C.
2, 3
D.
2, 4, 5
E.
4, 5

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Arrays

Discuss about this problem : Discuss in Forum


12.

Which one of the following classes are present System.Collections.Generic namespace?

  1. Stack
  2. Tree
  3. SortedDictionary
  4. SortedArray

A.
1 and 2 only
B.
2 and 4 only
C.
1 and 3 only
D.
All of the above
E.
None of the above

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Generics

Discuss about this problem : Discuss in Forum


13.

For the code snippet shown below, which of the following statements are valid?

public class Generic<T>
{
    public T Field; 
    public void TestSub()
    {
        T i = Field + 1;
    }
}
class MyProgram
{
    static void Main(string[] args)
    {
        Generic<int> gen = new Generic<int>();
        gen.TestSub();
    }
}

A.
Addition will produce result 1.
B.
Result of addition is system-dependent.
C.
Program will generate run-time exception.
D.
Compiler will report an error: Operator '+' is not defined for types T and int.
E.
None of the above.

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Generics

Discuss about this problem : Discuss in Forum


14.

For the code snippet shown below, which of the following statements are valid?

public class TestIndiaBix
{
    public void TestSub<M> (M arg)
    {
        Console.Write(arg);
    }
}
class MyProgram
{
    static void Main(string[] args)
    {
        TestIndiaBix bix = new TestIndiaBix();
        bix.TestSub("IndiaBIX ");
        bix.TestSub(4.2f);
    }
}

A.
Program will compile and on execution will print: IndiaBIX 4.2
B.
A non generic class Hello cannot have generic subroutine.
C.
Compiler will generate an error.
D.
Program will generate a run-time exception.
E.
None of the above.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Generics

Discuss about this problem : Discuss in Forum


15.

Which of the following CANNOT be used as an underlying datatype for an enum in C#.NET?

A.
byte
B.
short
C.
float
D.
int

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Enumerations

Discuss about this problem : Discuss in Forum


16.

Which of the following statements is correct about an enum used in C#.NET?

A.
enum is a reference type.
B.
enum is a value type.
C.
Whether it a value type or a reference type depends upon size.
D.
Whether it a value type or a reference type depends upon a Project Setting made in Visual Stiiclio.NET.
E.
We can programmatically control whether it is a value type or a reference type.

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Enumerations

Discuss about this problem : Discuss in Forum


17.

Which of the following statements are correct?

  1. The signature of an indexer consists of the number and types of its formal parameters.
  2. Indexers are similar to properties except that their accessors take parameters.
  3. Accessors of interface indexers use modifiers.
  4. The type of an indexer and the type of its parameters must be at least as accessible as the indexer itself.
  5. An interface accessor contains a body.

A.
1, 3, 5
B.
1, 2, 4
C.
3, 5
D.
2, 4

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Properties

Discuss about this problem : Discuss in Forum


18.

Which of the following is the correct way to implement a write only property Length in a Sample class?

A.
class Sample
{
    public int Length
    {
        set
        {
            Length = value;
        } 
    } 
}
B.
class Sample
{
    int len;
    public int Length
    {
        get
        {
            return len;
        }
        set
        {
            len = value;
        } 
    } 
}
C.
class Sample
{
    int len;
    public int Length
    {
        WriteOnly set
        {
            len = value;
        } 
    } 
}
D.
class Sample
{
    int len;
    public int Length
    {
        set
        {
            len = value;
        }
    } 
}

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Properties

Discuss about this problem : Discuss in Forum


19.

Which of the following statements is correct about the C#.NET program given below if a value "6" is input to it?

using System;
namespace IndiabixConsoleApplication
{
    class MyProgram
    {
        static void Main (string[] args)
        {
            int index; 
            int val = 66; 
            int[] a = new int[5]; 
            try
            {
                Consote.Write("Enter a number: "); 
                index = Convert.ToInt32(Console.ReadLine()); 
                a[index] = val;
            }
            catch(Exception e)
            {
                Console.Write("Exception occurred ");
            }
            Console.Write("Remaining program ");
        }
    }
}

A.
It will output: Exception occurred
B.
It will output: Remaining program
C.
It will output: Exception occurred Remaining program
D.
It will output: Remaining program Exception occurred
E.
The value 66 will get assigned to a[6].

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Exception Handling

Discuss about this problem : Discuss in Forum


20.

Which of the following statements are correct?

  1. All operators in C#.NET can be overloaded.
  2. We can use the new modifier to modify a nested type if the nested type is hiding another type.
  3. In case of operator overloading all parameters must be of the different type than the class or struct that declares the operator.
  4. Method overloading is used to create several methods with the same name that performs similar tasks on similar data types.
  5. Operator overloading permits the use of symbols to represent computations for a type.

A.
1, 3
B.
2, 4
C.
2, 5
D.
3, 4

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Polymorphism

Discuss about this problem : Discuss in Forum


Submit your test now to view the Results and Statistics with answer explanation.