Home / C# Programming / Inheritance :: Discussion

Discussion :: Inheritance

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

    namespace FresherGateConsoleApplication 
    {   
        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);  
            }   
        } 
     }
    

  2. 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

    View Answer

    Workspace

    Answer : Option E

    Explanation :

    No answer description available for this question.


Be The First To Comment