using System; class superclass { private int x = 1; protected static int y = 1; public void f() { Console.WriteLine("I'm the f in superclass\n"); } public virtual void g() { Console.WriteLine("I'm the g in superclass\n"); } } class subclass : superclass { public new int x = 1; public new void f() { Console.WriteLine("I'm the f in subclass\n"); } public override void g() { x++; y++; Console.WriteLine("x is " + x + " and y is " + y); } } public class goodquestion { public static void Main(string[] args) { superclass A; subclass B1; A = new subclass(); // A has different static and dynamic types B1 = new subclass(); A.f(); A.g(); B1.f(); B1 = (subclass)A; // why is this cast necessary, why is it valid? B1.f(); } }