Exercise: Constructors
Questions for: Constructors
What will be the output of the C#.NET code snippet given below?
namespace ExamAdept
{
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 methodB:
Bix1 method
123
Bix2 methodC:
Bix2 method
123
Bix2 method
Bixl methodD:
Bixl method
123
Answer: A
No answer description is available. Let's discuss.
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.
Answer: C
No answer description is available. Let's discuss.
Discuss About this Question.
What will be the output of the C#.NET code snippet given below?
namespace ExamAdept
{
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
Answer: A
No answer description is available. Let's discuss.
Discuss About this Question.
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.
Answer: D
No answer description is available. Let's discuss.
Discuss About this Question.
Is it possible for you to prevent an object from being created by using zero argument constructor?
A:
Yes
B:
No
C:
D:
Answer: A
No answer description is available. Let's discuss.
Discuss About this Question.
Ad Slot (Above Pagination)
Discuss About this Question.