322.
class BC { public void Display() { System.Console.WriteLine("BC::Display"); } } class DC : BC { new public void Display() { System.Console.WriteLine("DC::Display"); } } class TC : BC { new public void Display() { System.Console.WriteLine("TC::Display"); } } class Demo { public static void Main() { BC b; b = new BC(); b.Display(); b = new DC(); b.Display(); b = new TC(); b.Display(); } } What is the output?
View Description
The output of the above program is a receipt of the fact that no matter to whom base class reference b refers, it invokes the functions of the class that matches its type. But doesn't this sound absurd? If b contains the reference to a perticular derived class object, then its supposed to invoke the function of that class.