Online C# Programming Test - C# Programming Test 7



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 .NET components can be used to remove unused references from the managed heap?

A.
Common Language Infrastructure
B.
CLR
C.
Garbage Collector
D.
Class Loader
E.
CTS

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : .NET Framework

Discuss about this problem : Discuss in Forum


2.

Which of the following assemblies can be stored in Global Assembly Cache?

A.
Private Assemblies
B.
Friend Assemblies
C.
Shared Assemblies
D.
Public Assemblies
E.
Protected Assemblies

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : .NET Framework

Discuss about this problem : Discuss in Forum


3.

Which of the following does not store a sign?

A.
Short
B.
Integer
C.
Long
D.
Byte
E.
Single

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Datatypes

Discuss about this problem : Discuss in Forum


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

A.
0.1
B.
1.0
C.
1.1
D.
11

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Datatypes

Discuss about this problem : Discuss in Forum


5.

Which of the following statements is correct?

A.
A constructor can be used to set default values and limit instantiation.
B.
C# provides a copy constructor.
C.
Destructors are used with classes as well as structures.
D.
A class can have more than one destructor.

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Constructors

Discuss about this problem : Discuss in Forum


6.

Which of the following statements are correct about static functions?

  1. Static functions can access only static data.
  2. Static functions cannot call instance functions.
  3. It is necessary to initialize static data.
  4. Instance functions can call static functions and access static data.
  5. this reference is passed to static functions.

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

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Constructors

Discuss about this problem : Discuss in Forum


7.

Which of the following statements are correct about the C#.NET code snippet given below?

class Sample
{
    static int i;
    int j;
    public void proc1()
    {
        i = 11; 
        j = 22;
    }
    public static void proc2()
    {
        i = 1;
        j = 2;
    }
    static Sample()
    {
        i = 0; 
        j = 0;
    }
}

A.
i cannot be initialized in proc1().
B.
proc1() can initialize i as well as j.
C.
j can be initialized in proc2().
D.
The constructor can never be declared as static.
E.
proc2() can initialize i as well as j.

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Constructors

Discuss about this problem : Discuss in Forum


8.

Multiple inheritance is different from multiple levels of inheritance.

A.
True
B.
False

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Multiple inheritance means deriving a class from more than one classes. On the other hand, multiple levels of inheritance means a class has been derived from a base class and the base class itself has been derived from another base class. Multiple inheritance is not permitted in C#.NET.

Learn more problems on : Inheritance

Discuss about this problem : Discuss in Forum


9.

The way a derived class member function can access base class public members, the base class member functions can access public member functions of derived class.

A.
True
B.
False

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Base class cannot access derived class members since it does not have any knowledge of the derived class.

Learn more problems on : Inheritance

Discuss about this problem : Discuss in Forum


10.

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

String s1 = "ALL MEN ARE CREATED EQUAL";
String s2;
s2 = s1.Substring(12, 3); 
Console.WriteLine(s2);

A.
ARE
B.
CRE
C.
CR
D.
REA
E.
CREATED

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Strings

Discuss about this problem : Discuss in Forum


11.

Which of the following statement is correct about a String in C#.NET?

A.
A String is mutable because it can be modified once it has been created.
B.
Methods of the String class can be used to modify the string.
C.
A number CANNOT be represented in the form of a String.
D.
A String has a zero-based index.
E.
The System.Array class is used to represent a string.

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Strings

Discuss about this problem : Discuss in Forum


12.

Which of the following is the correct way to call the function MyFun() of the Sample class given below?

class Sample
{
    public int MyFun(int i)
    {
        Console.WriteLine("Welcome to IndiaBIX.com !" );
        return 0;
    }
}

A.
delegate void del(int i);
Sample s = new Sample();
deld = new del(ref s.MyFun);
d(10);
B.
delegate int del(int i);
Sample s = new Sample(.);
del = new delegate(ref MyFun);
del(10);
C.
Sample s = new Sample();
delegate void del = new delegate(ref MyFun);
del(10);
D.
delegate int del(int i);
del d;
Sample s = new Sample();
d = new del(ref s.MyFun);
d(10);

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Delegates

Discuss about this problem : Discuss in Forum


13.

Suppose on pushing a button an object is to be notified, but it is not known until runtime which object should be notified. Which of the following programming constructs should be used to implement this idea?

A.
Attribute
B.
Delegate
C.
Namespace
D.
Interface
E.
Encapsulation

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Delegates

Discuss about this problem : Discuss in Forum


14.

A HashTable t maintains a collection of names of states and capital city of each state. Which of the following is the correct way to find out whether "Kerala" state is present in this collection or not?

A.
t.ContainsKey("Kerala");
B.
t.HasValue("Kerala");
C.
t.HasKey("Kerala");
D.
t.ContainsState("Kerala");
E.
t.ContainsValue("Kerala");

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Collection Classes

Discuss about this problem : Discuss in Forum


15.

If Sample class has a Length property with get and set accessors then which of the following statements will work correctly?

  1. Sample.Length = 20;
  2. Sample m = new Sample(); 
    m.Length = 10;
  3. Console.WriteLine(Sample.Length);
  4. Sample m = new Sample(); 
    int len;
    len = m.Length;
  5. Sample m = new Sample(); 
    m.Length = m.Length + 20;

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

Your Answer: Option (Not Answered)

Correct Answer: Option B

Learn more problems on : Properties

Discuss about this problem : Discuss in Forum


16.

Which of the following statements is correct about an Exception?

A.
It occurs during compilation.
B.
It occurs during linking.
C.
It occurs at run-time.
D.
It occurs during Just-In-Time compilation.
E.
It occurs during loading of the program.

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Exception Handling

Discuss about this problem : Discuss in Forum


17.

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

using System;
namespace IndiabixConsoleApplication
{
    class MyProgram
    {
        static void Main(string[] args)
        {
            int index; 
            int vat = 88;
            int[] a = new int(5];
            try
            {
                Console.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: Remaining program Exception occurred
D.
It will output: Exception occurred Remaining program
E.
The value 88 will get assigned to a[0].

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Exception Handling

Discuss about this problem : Discuss in Forum


18.

Which of the following is the correct way to overload + operator?

A.
public sample operator + ( sample a, sample b )
B.
public abstract operator + ( sample a, sample b)
C.
public abstract sample operator + (sample a, sample b )
D.
public static sample operator + ( sample a, sample b )
E.
All of the above

Your Answer: Option (Not Answered)

Correct Answer: Option D

Learn more problems on : Polymorphism

Discuss about this problem : Discuss in Forum


19.

Which of the following statements is correct?

A.
Only one object can be created from an abstract class.
B.
By default methods are virtual.
C.
If a derived class does not provide its own version of virtual method then the one in the base class is used.
D.
If the method in the derived class is not preceded by override keywords, the compiler will issue a warning and the method will behave as if the override keyword were present.
E.
Each derived class does not have its own version of a virtual method.

Your Answer: Option (Not Answered)

Correct Answer: Option C

Learn more problems on : Polymorphism

Discuss about this problem : Discuss in Forum


20.

Which of the following is the correct way to implement the interface given below?

interface IPerson
{ 
    String FirstName
    {
        get;
        set; 
    } 
}

A.
class Employee : IPerson
{
    private String str; 
    public String FirstName
    {
        get
        { 
            return str;
        } 
        set
        { 
            str = value;
        } 
    } 
}
B.
class Employee
{
    private String str;
    public String IPerson.FirstName
    { 
        get
        { 
            return str;
        } 
        set
        { 
            str = value;
        } 
    } 
}
C.
class Employee : implements IPerson
{
    private String str; 
    public String FirstName
    { 
        get
        { 
            return str;
        } 
        set
        {
            str = value; 
        } 
    } 
}
D.
None of the above

Your Answer: Option (Not Answered)

Correct Answer: Option A

Learn more problems on : Interfaces

Discuss about this problem : Discuss in Forum


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