Examveda

What will be the Correct statement in the following C# code?
class baseclass
{
    int a;
    public baseclass(int a1) 
    {
        a = a1;
        console.writeline(" a ");
    }
    class derivedclass : baseclass
    {
        public derivedclass (int a1) : base(a1)
        {
            console.writeline(" b ");
        }
    }
    class program
    {
        static void main(string[] args)
        {
            derivedclass d =  new derivedclass(20);
        }
    }
}

A. Compile time error

B. b
a

C. a
b

D. The program will work correctly if we replace base(a1) with base.baseclass(a1)

Answer: Option C


Join The Discussion

Related Questions on Classes and Objects in C Sharp