public abstract class A {
   public string PublicPrint() { 
      return Print(); 
   } 
 
   protected virtual string Print() {
        return "A"; 
   } 
}
 public class B : A { } 
 public class C : B { 
     protected override string Print() { 
         return "C"; 
     } 
}
 
What will be the result of the following code execution?
 
A ac = new C(); 
Console.WriteLine(ac.PublicPrint());
 
Explanation
This question is about basic rule of polymorphism. Code is calling an overloaded method. This method must be marked as virtual in a base class and must have "override" keyword in its signature in derived class.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Cosmo
Зареєструйся Зараз
або Підпишись на майбутні тести