C# Programming - Inheritance
Why should I learn to solve C# Programming questions and answers section on "Inheritance"?
Learn and practise solving C# Programming questions and answers section on "Inheritance" to enhance your skills so that you can clear interviews, competitive examinations, and various entrance tests (CAT, GATE, GRE, MAT, bank exams, railway exams, etc.) with full confidence.
Where can I get the C# Programming questions and answers section on "Inheritance"?
IndiaBIX provides you with numerous C# Programming questions and answers based on "Inheritance" along with fully solved examples and detailed explanations that will be easy to understand.
Where can I get the C# Programming section on "Inheritance" MCQ-type interview questions and answers (objective type, multiple choice)?
Here you can find multiple-choice C# Programming questions and answers based on "Inheritance" for your placement interviews and competitive exams. Objective-type and true-or-false-type questions are given too.
How do I download the C# Programming questions and answers section on "Inheritance" in PDF format?
You can download the C# Programming quiz questions and answers section on "Inheritance" as PDF files or eBooks.
How do I solve C# Programming quiz problems based on "Inheritance"?
You can easily solve C# Programming quiz problems based on "Inheritance" by practising the given exercises, including shortcuts and tricks.
- Inheritance - General Questions
- Inheritance - True or False
- Use the existing functionality of base class.
- Overrride the existing functionality of base class.
- Implement new functionality in the derived class.
- Implement polymorphic behaviour.
- Implement containership.
class BaseClass
{
protected int i = 13;
}
class Derived: BaseClass
{
int i = 9;
public void fun()
{
// [*** Add statement here ***]
}
}
namespace IndiabixConsoleApplication
{
class index
{
protected int count;
public index()
{
count = 0;
}
}
class index1: index
{
public void increment()
{
count = count +1;
}
}
class MyProgram
{
static void Main(string[] args)
{
index1 i = new index1();
i.increment();
}
}
}
- count should be declared as public if it is to become available in the inheritance chain.
- count should be declared as protected if it is to become available in the inheritance chain.
- While constructing an object referred to by i firstly constructor of index class will be called followed by constructor of index1 class.
- Constructor of index class does not get inherited in index1 class.
- count should be declared as Friend if it is to become available in the inheritance chain.
namespace IndiabixConsoleApplication
{
class Baseclass
{
private int i;
protected int j;
public int k;
}
class Derived: Baseclass
{
private int x;
protected int y;
public int z;
}
class MyProgram
{
static void Main (string[ ] args)
{
Derived d = new Derived();
}
}
}
namespace IndiabixConsoleApplication
{
class A
{
public void fun()
{
Console.Write("Welcome");
}
}
class B: A
{
public void fun()
{
// [*** Add statement here ***]
Console.WriteLine(" to IndiaBIX.com!");
}
}
class MyProgram
{
static void Main (string[ ] args)
{
B b = new B();
b.fun();
}
}
}