C# Programming - Inheritance
Exercise : Inheritance - General Questions
- Inheritance - General Questions
- Inheritance - True or False
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();
}
}
}
7.
Which of the following should be used to implement a 'Has a' relationship between two entities?
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);
}
}
}
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
10.
Which of the following are reuse mechanisms available in C#.NET?
- Inheritance
- Encapsulation
- Templates
- Containership
- Polymorphism
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers