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
Зарегистрируйся сейчас
или Подпишись на будущие тесты