C# Programming - Inheritance

Exercise : Inheritance - General 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(); 
        } 
    } 
}
Base class
Derived1 class
Derived2 class
Base class Derived1 class
Base class Derived1 class Derived2 class
Answer: Option
Explanation:
No answer description is available. Let's discuss.

7.
Which of the following should be used to implement a 'Has a' relationship between two entities?
Polymorphism
Templates
Containership
Encapsulation
Inheritance
Answer: Option
Explanation:
No answer description is available. Let's discuss.

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);
        } 
    } 
}
The program gives the output as: Hi Hello Bye
The program gives the output as: Bye Hello
The program gives the output as: Hi Bye Hello
Error in the program
Answer: Option
Explanation:
No answer description is available. Let's discuss.

9.
In an inheritance chain which of the following members of base class are accessible to the derived class members?
  1. static
  2. protected
  3. private
  4. shared
  5. public
1, 3
2, 5
3, 4
4, 5
Answer: Option
Explanation:
No answer description is available. Let's discuss.

10.
Which of the following are reuse mechanisms available in C#.NET?
  1. Inheritance
  2. Encapsulation
  3. Templates
  4. Containership
  5. Polymorphism
1, 4
1, 3
2, 4
3, 5
Answer: Option
Explanation:
No answer description is available. Let's discuss.