Exercise: Inheritance

Questions for: Inheritance

Which of the following statements should be added to the subroutine fun( ) if the C#.NET code snippet given below is to output 9 13?
class BaseClass
{
    protected int i = 13;
}
class Derived: BaseClass
{
    int i = 9; 
    public void fun()
    {
        // [*** Add statement here ***]
    } 
}
A:
Console.WriteLine(base.i + " " + i);
B:
Console.WriteLine(i + " " + base.i);
C:
Console.WriteLine(mybase.i + " " + i);
D:
Console.WriteLine(i + " " + mybase.i);
Answer: B
No answer description is available. Let's discuss.
Which of the following can be facilitated by the Inheritance mechanism?
  1. Use the existing functionality of base class.
  2. Overrride the existing functionality of base class.
  3. Implement new functionality in the derived class.
  4. Implement polymorphic behaviour.
  5. Implement containership.
A:
1, 2, 3
B:
3, 4
C:
2, 4, 5
D:
3, 5
Answer: A
No answer description is available. Let's discuss.
Ad Slot (Above Pagination)
Quiz