constructors programing questions

16.

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
E.     Sample class Sample class
Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
17.

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.
E.     this reference is never passed to a constructor.
Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
18.

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

E.

Bix2 method
123
Bixl method

Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question.

Leave a Reply0

Your email address will not be published.