public abstract class A
 {
        public virtual string Print() { return "A"; }
 }

 public class B : A 
{
    public override new string Print() { return "B"; }
 }

 public class C : B
 { 
   public string Print() { return "C"; }
 
}
 
What will be the result of the following code execution?:
 A ac = new C();
 Console.WriteLine(ac.Print());
 
Explanation
Overriding a method while using a new modifier in one statement is unacceptable since two modifiers have mutually exclusive meanings.

@laor31692 fixed ;)

2017 Dec 15, 1:49:30 PM

public virtual string Print() { return "A" } After return statement there should be semicolon, or will be compilation error :)

2017 Dec 15, 9:46:52 AM

C#
C# Quiz
Start Quiz

or Read more about C# Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback