Online C# Programming Test - C# Programming Test 1



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 utilities can be used to compile managed assemblies into processor-specific native code?

A.
gacutil
B.
ngen
C.
sn
D.
dumpbin
E.
ildasm

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 are value types?

  1. Integer
  2. Array
  3. Single
  4. String
  5. Long

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Datatypes

Discuss about this problem : Discuss in Forum


3.

Which of the following are the correct way to initialise the variables i and j to a value 10 each?

  1. int i = 10; int j = 10;
  2. int i, j;
    i = 10 : j = 10;
  3. int i = 10, j = 10;
  4. int i, j = 10;
  5. int i = j = 10;

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Datatypes

Discuss about this problem : Discuss in Forum


4.

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

namespace IndiabixConsoleApplication
{
    public enum color
    { red, green, blue };
    
    class SampleProgram
    {
        static void Main (string[ ] args)
        {
            color c = color.blue;
            switch (c)
            {
                case color.red:
                    Console.WriteLine(color.red); 
                    break; 
                
                case color.green: 
                    Console.WriteLine(color.green); 
                    break; 
                
                case color.blue: 
                    Console.WriteLine(color.blue); 
                    break; 
            } 
        } 
    } 
}

A.
red
B.
blue
C.
0
D.
1
E.
2

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Control Instructions

Discuss about this problem : Discuss in Forum


5.

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

int i = 2, j = i;
if (Convert.ToBoolean((i | j & 5) & (j - 25 * 1)))
    Console.WriteLine(1); 
else
    Console.WriteLine(0);

A.
0
B.
1
C.
Compile Error
D.
Run time Error

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Control Instructions

Discuss about this problem : Discuss in Forum


6.

In which of the following should the methods of a class differ if they are to be treated as overloaded methods?

  1. Type of arguments
  2. Return type of methods
  3. Number of arguments
  4. Names of methods
  5. Order of arguments

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

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Constructors

Discuss about this problem : Discuss in Forum


7.

How can you prevent inheritance from a class in C#.NET ?

A.
Declare the class as shadows.
B.
Declare the class as overloads.
C.
Declare the class as sealed.
D.
Declare the class as suppress.
E.
Declare the class as override.

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

C#.NET allows sealed attribute to be used as a part of class statement. Classes declared with sealed keyword cannot be used as based class for other classes. Most important reason to do this world be to prevent behavior of a class to be changed in any way.

Learn more problems on : Inheritance

Discuss about this problem : Discuss in Forum


8.

Assume class B is inherited from class A. Which of the following statements is correct about construction of an object of class B?

A.
While creating the object firstly the constructor of class B will be called followed by constructor of class A.
B.
While creating the object firstly the constructor of class A will be called followed by constructor of class B.
C.
The constructor of only class B will be called.
D.
The constructor of only class A will be called.
E.
The order of calling constructors depends upon whether constructors in class A and class B are private or public.

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Inheritance

Discuss about this problem : Discuss in Forum


9.

If s1 and s2 are references to two strings then which of the following are the correct ways to find whether the contents of the two strings are equal?

  1. if(s1 = s2)
  2. if(s1 == s2)
  3. int c;
    c = s1.CompareTo(s2);
  4. if( strcmp(s1, s2) )
  5. if (s1 is s2)

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Strings

Discuss about this problem : Discuss in Forum


10.

Which of the following statements are correct about delegates?

A.
Delegates cannot be used to call a static method of a class.
B.
Delegates cannot be used to call procedures that receive variable number of arguments.
C.
If signatures of two methods are same they can be called through the same delegate object.
D.
Delegates cannot be used to call an instance function. Delegates cannot be used to call an instance subroutine.

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Delegates

Discuss about this problem : Discuss in Forum


11.

Which of the following forms of applying an attribute is correct?

A.
< Serializable() > class sample
{ /* ... */ }
B.
(Serializable()) class sample
{ /* ... */ }
C.
[ Serializable() ] class sample
{ /* ... */ }
D.
Serializablef) class sample
{ /* ... */ }
E.
None of the above

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Attributes

Discuss about this problem : Discuss in Forum


12.

Once applied which of the following CANNOT inspect the applied attribute?

A.
CLR
B.
Linker
C.
ASP.NET Runtime
D.
Visual Studio.NET
E.
Language compilers

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Attributes

Discuss about this problem : Discuss in Forum


13.

Which of the following is the correct output for the C#.NET code snippet given below?

enum color: int
{ 
    red,
    green, 
    blue = 5, 
    cyan,
    magenta = 10, 
    yellow 
}
Console.Write( (int) color.green + ", " ); 
Console.Write( (int) color.yellow );

A.
2, 11
B.
1, 11
C.
2, 6
D.
1, 5
E.
None of the above

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Enumerations

Discuss about this problem : Discuss in Forum


14.

A Student class has a property called rollNo and stu is a reference to a Student object and we want the statement stu.RollNo = 28 to fail. Which of the following options will ensure this functionality?

A.
Declare rollNo property with both get and set accessors.
B.
Declare rollNo property with only set accessor.
C.
Declare rollNo property with get, set and normal accessors.
D.
Declare rollNo property with only get accessor.
E.
None of the above

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Properties

Discuss about this problem : Discuss in Forum


15.

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

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

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Properties

Discuss about this problem : Discuss in Forum


16.

If a namespace is present in a library then which of the following is the correct way to use the elements of the namespace?

A.
Add Reference of the namespace.
Use the elements of the namespace.
B.
Add Reference of the namespace.
Import the namespace.
Use the elements of the namespace.
C.
Import the namespace.
Use the elements of the namespace.
D.
Copy the library in the same directory as the project that is trying to use it.
Use the elements of the namespace.
E.
Install the namespace in Global Assembly Cache.
Use the elements of the namespace.

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Namespaces

Discuss about this problem : Discuss in Forum


17.

In C#.NET if we do not catch the exception thrown at runtime then which of the following will catch it?

A.
Compiler
B.
CLR
C.
Linker
D.
Loader
E.
Operating system

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Exception Handling

Discuss about this problem : Discuss in Forum


18.

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.

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

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Exception Handling

Discuss about this problem : Discuss in Forum


19.

All code inside finally block is guaranteed to execute irrespective of whether an exception occurs in the protected block or not.

A.
True
B.
False

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Exception Handling

Discuss about this problem : Discuss in Forum


20.

Which of the following unary operators can be overloaded?

  1. true
  2. false
  3. +
  4. new
  5. is

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

Your Answer: Option (Not Answered)

Correct Answer: Option A

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.