Inheritance c programming questions

6.

What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
class Baseclass
{
public void fun()
{
Console.Write(“Base class” + ” “);
}
}
class Derived1: Baseclass
{
new void fun()
{
Console.Write(“Derived1 class” + ” “);
}
}
class Derived2: Derived1
{
new void fun()
{
Console.Write(“Derived2 class” + ” “);
}
}
class Program
{
public static void Main(string[ ] args)
{
Derived2 d = new Derived2();
d.fun();
}
}
}

A.     Base class
B.     Derived1 class
C.     Derived2 class
D.     Base class Derived1 class
E.     Base class Derived1 class Derived2 class
Answer & Explanation

Answer: Option A

Explanation:

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

Which of the following should be used to implement a ‘Has a’ relationship between two entities?
A.     Polymorphism    B.     Templates
C.     Containership    D.     Encapsulation
E.     Inheritance
Answer & Explanation

Answer: Option C

Explanation:

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

Which of the following is correct about the C#.NET snippet given below?

namespace IndiabixConsoleApplication
{
class Baseclass
{
public void fun()
{
Console.WriteLine(“Hi” + ” “);
}
public void fun(int i)
{
Console.Write(“Hello” + ” “);
}
}
class Derived: Baseclass
{
public void fun()
{
Console.Write(“Bye” + ” “);
}
}
class MyProgram
{
static void Main(string[ ] args)
{
Derived d;
d = new Derived();
d.fun();
d.fun(77);
}
}
}

A.     The program gives the output as: Hi Hello Bye
B.     The program gives the output as: Bye Hello
C.     The program gives the output as: Hi Bye Hello
D.     Error in the program
Answer & Explanation

Answer: Option B

Explanation:

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

In an inheritance chain which of the following members of base class are accessible to the derived class members?

static
protected
private
shared
public

A.     1, 3
B.     2, 5
C.     3, 4
D.     4, 5
Answer & Explanation

Answer: Option B

Explanation:

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

Which of the following are reuse mechanisms available in C#.NET?

Inheritance
Encapsulation
Templates
Containership
Polymorphism

A.     1, 4
B.     1, 3
C.     2, 4
D.     3, 5
Answer & Explanation

Answer: Option A

Explanation:

No answer description available for this question.

Leave a Reply0

Your email address will not be published.