Inheritance

Q1: Which of the following statements is correct about the C#.NET program given below?
namespace AptitudeCrackConsoleApplication
{
    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 work correctly only if we implement zero-argument constructors in Baseclass as well as Derived class.

B The program will output: Derived Base

C The program will report an error in the statement base(ii).

D The program will work correctly if we replace base(ii) with base.Baseclass(ii).

E The program will output: Base Derived

ANS:E - The program will output: Base Derived

No answer description is available. Let's discuss.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.