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

namespace PskillsConsoleApplication
{
    class Baseclass
    {
        int i;
        public Baseclass(int ii)
        {
            i = ii;
            Console.Write("Base ");
        }
    }
    class Derived : Baseclass
    {
        public Derived(int ii) : base(ii)
        {
            Console.Write("Derived ");
        }
    }
    class MyProgram
    {
        static void Main(string[ ] args)
        {
            Derived d = new Derived(10);
        }
    }
}
A. The program will report an error in the statement base(ii).
B. The program will work correctly if we replace base(ii) with base.Baseclass(ii).
C. The program will output: Base Derived
D. The program will work correctly only if we implement zero-argument constructors in Baseclass as well as Derived class.

Ans: C

0 comments:

Post a Comment