Which of the following statements are correct about constructors in C#.NET?
1/ Constructors cannot be overloaded.
2/ Constructors always have the name same as the name of the class.
3/ Constructors are never called explicitly.
4/ Constructors never return any value.
5/ Constructors allocate space for the object in memory.
A -
2, 3, 4
B -
3, 5
C -
4, 5
D -
None of these
2-
How many times can a constructor be called during lifetime of the object?
A -
As many times as we call it.
B -
Only once.
C -
Depends upon a Project Setting made in Visual Studio.NET.
D -
Any number of times before the object gets garbage collected.
3-
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.
4-
Which of the following statements is correct?
A -
There is one garbage collector per program running in memory.
B -
There is one common garbage collector for all programs.
C -
An object is destroyed by the garbage collector when only one reference refers to it.
D -
We have to specifically run the garbage collector after executing Visual Studio.NET.
5-
Which of the following statements are correct about static functions?
A -
Static functions are invoked using objects of a class.
B -
Static functions can access static data as well as instance data.
C -
Static functions are outside the class scope.
D -
Static functions are invoked using class.
6-
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
7-
Which of the following statements is correct about constructors in C#.NET?
A -
A constructor cannot be declared as private.
B -
A constructor cannot be overloaded.
C -
A constructor can be a static constructor.
D -
A constructor cannot access static data.
8-
What will be the output of the C#.NET code snippet given below?
namespace IndiabixConsoleApplication
{
class Sample
{
public static void fun1()
{
Console.WriteLine("Bix1 method");
}
public void fun2()
{
fun1();
Console.WriteLine("Bix2 method");
}
public void fun2(int i)
{
Console.WriteLine(i);
fun2();
}
}
class MyProgram
{
static void Main(string[ ] args)
{
Sample s = new Sample();
Sample.fun1();
s.fun2(123);
}
}
}
A -
Bix1 method 123 Bixl method Bix2 method
B -
Bix1 method 123 Bix2 method
C -
Bix2 method 123 Bix2 method Bixl method
D -
Bixl method 123
9-
Which of the following can be facilitated by the Inheritance mechanism?
1/ Use the existing functionality of base class.
2/ Overrride the existing functionality of base class.
3/ Implement new functionality in the derived class.
4/ Implement polymorphic behaviour.
5/ Implement containership.
A -
1, 2, 3
B -
3, 4
C -
2, 4, 5
D -
3, 5
10-
Which of the following statements should be added to the subroutine fun( ) if the C#.NET code snippet given below is to output 9 13?
class BaseClass
{
protected int i = 13;
}
class Derived: BaseClass
{
int i = 9;
public void fun()
{
// [*** Add statement here ***]
}
}