Online C# Programming Test - C# Programming Test 7

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 assemblies can be stored in Global Assembly Cache?
Private Assemblies
Friend Assemblies
Shared Assemblies
Public Assemblies
Protected Assemblies
Your Answer: Option
(Not Answered)
Correct Answer: Option

2.
Which of the following .NET components can be used to remove unused references from the managed heap?
Common Language Infrastructure
CLR
Garbage Collector
Class Loader
CTS
Your Answer: Option
(Not Answered)
Correct Answer: Option

3.
Which of the following does not store a sign?
Short
Integer
Long
Byte
Single
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 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

6.
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;
    }
}
i cannot be initialized in proc1().
proc1() can initialize i as well as j.
j can be initialized in proc2().
The constructor can never be declared as static.
proc2() can initialize i as well as j.
Your Answer: Option
(Not Answered)
Correct Answer: Option

7.
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.
1, 2, 4
2, 3, 5
3, 4
4, 5
None of these
Your Answer: Option
(Not Answered)
Correct Answer: Option

8.
Multiple inheritance is different from multiple levels of inheritance.
True
False
Your Answer: Option
(Not Answered)
Correct Answer: Option
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.

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.
True
False
Your Answer: Option
(Not Answered)
Correct Answer: Option
Explanation:
Base class cannot access derived class members since it does not have any knowledge of the derived class.

10.
Which of the following statement is correct about a String in C#.NET?
A String is mutable because it can be modified once it has been created.
Methods of the String class can be used to modify the string.
A number CANNOT be represented in the form of a String.
A String has a zero-based index.
The System.Array class is used to represent a string.
Your Answer: Option
(Not Answered)
Correct Answer: Option

11.
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);
ARE
CRE
CR
REA
CREATED
Your Answer: Option
(Not Answered)
Correct Answer: Option

12.
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?
Attribute
Delegate
Namespace
Interface
Encapsulation
Your Answer: Option
(Not Answered)
Correct Answer: Option

13.
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;
    }
}
delegate void del(int i);
Sample s = new Sample();
deld = new del(ref s.MyFun);
d(10);
delegate int del(int i);
Sample s = new Sample(.);
del = new delegate(ref MyFun);
del(10);
Sample s = new Sample();
delegate void del = new delegate(ref MyFun);
del(10);
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

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?
t.ContainsKey("Kerala");
t.HasValue("Kerala");
t.HasKey("Kerala");
t.ContainsState("Kerala");
t.ContainsValue("Kerala");
Your Answer: Option
(Not Answered)
Correct Answer: Option

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;
1, 3
2, 4, 5
4 only
3, 5
Your Answer: Option
(Not Answered)
Correct Answer: Option

16.
Which of the following statements is correct about an Exception?
It occurs during compilation.
It occurs during linking.
It occurs at run-time.
It occurs during Just-In-Time compilation.
It occurs during loading of the program.
Your Answer: Option
(Not Answered)
Correct Answer: Option

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");
        }
    }
}
It will output: Exception occurred
It will output: Remaining program
It will output: Remaining program Exception occurred
It will output: Exception occurred Remaining program
The value 88 will get assigned to a[0].
Your Answer: Option
(Not Answered)
Correct Answer: Option

18.
Which of the following is the correct way to overload + operator?
public sample operator + ( sample a, sample b )
public abstract operator + ( sample a, sample b)
public abstract sample operator + (sample a, sample b )
public static sample operator + ( sample a, sample b )
All of the above
Your Answer: Option
(Not Answered)
Correct Answer: Option

19.
Which of the following statements is correct?
Only one object can be created from an abstract class.
By default methods are virtual.
If a derived class does not provide its own version of virtual method then the one in the base class is used.
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.
Each derived class does not have its own version of a virtual method.
Your Answer: Option
(Not Answered)
Correct Answer: Option

20.
Which of the following is the correct way to implement the interface given below?
interface IPerson
{ 
    String FirstName
    {
        get;
        set; 
    } 
}
class Employee : IPerson
{
    private String str; 
    public String FirstName
    {
        get
        { 
            return str;
        } 
        set
        { 
            str = value;
        } 
    } 
}
class Employee
{
    private String str;
    public String IPerson.FirstName
    { 
        get
        { 
            return str;
        } 
        set
        { 
            str = value;
        } 
    } 
}
class Employee : implements IPerson
{
    private String str; 
    public String FirstName
    { 
        get
        { 
            return str;
        } 
        set
        {
            str = value; 
        } 
    } 
}
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: