Multiple choice

What will be the output of the following code? using System;using System.Collections.Generic;class A { public void Demo() { Console.WriteLine(The Demo in base class); } } class B : A { public override void Demo() { Console.WriteLine(The Demo in child class); } } class test { static void Main(string[] args) { B b = new B(); b.Demo(); } }

  1. The Demo in base class

  2. The Demo in child class

  3. Compilation error.

  4. The code will compile properly but will not produce any output.

  5. None of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Yes, the code will give compilation error as there is 'virtual' keyword missing in the method of the base class, hence it will not be inherited.