title: Virtual method can be used in derived class
body: <p>Is it possible to write virtual method in derived class and invoking a parent class which has a override method. I was asked in an interview , I gave ans that it will give error because virtual can be declared in parent/base class not in derived class</p>
  
  <p>namespace Polymorphism
  {
      public class parent
      {
          public virtual void print()
          {
              Console.WriteLine("parent class");
          }
      }</p>
  
  <pre><code>public class derive : parent
  {
      public override void print()
      {
          Console.WriteLine("Derived Class");
      }
  }
  
  public class ddd : derive
  {
      public override void print()
      {
          Console.WriteLine("invoke DDDDd");
      }
  }
  class Program
  {
      static void Main(string[] args)
      {
          parent p = new derive();
         // p = new ddd();
          p.print();
  
      }
  }
  </code></pre>
  
  <p>}</p>