Author : Rahul

What will be the output of below program.


Code

using System;

namespace InterviewQuestion
{
   public class BaseClass
   {
       static BaseClass()
       {
           Console.WriteLine("Inside BaseClass static constructor.");
       }
       
       public BaseClass()
       {
           Console.WriteLine("Inside BaseClass constructor.");
       }
   }
   
   public class DerivedClass : BaseClass
   {
       static DerivedClass()
       {
           Console.WriteLine("Inside DerivedClass static constructor.");
       }
       
       public DerivedClass()
       {
           Console.WriteLine("Inside DerivedClass constructor.");
       }
   }
   
   class Program
   {
       static void Main(string[] args)
       {
           BaseClass baseClass = new DerivedClass();
       }
   }
}

Output

Inside DerivedClass static constructor.
Inside BaseClass static constructor.
Inside BaseClass constructor.
Inside DerivedClass constructor.