Multiple choice

Which of the following is true about 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 new void Demo() { Console.WriteLine(The Demo in child class); } } class test { static void Main(string[] args) { A b = new B(); b.Demo(); } }

  1. It will print the method of the base class.

  2. It will print the method of the child class.

  3. It will not compile because base class method is not marked as virtual.

  4. It will not compile because child class method is not marked as override.

  5. None of the above

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

Yes, the base class method is called as we used the new keyword in the child class, so the method can not be override. Hence the method of the B class would not be called.