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(); 
The basic rule of polymorphism. The overloaded method is called, that is defined in the object, instance of which was created. In this case, method must be marked as virtual in the base class, and it must have "override" in the derived class.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
C# quizzes
Sign Up Now
or Subscribe for future quizzes