In this code, the A type is used to reference the B and C types. When the A type references a B instance, the Y override from B is used. But when the A type references a C instance, the Y method from the base class A is used.
The override modifier was not used.
The C.Y method is local to the C type.
In the program, the C type generates a warning because C.Y hides A.Y. Your program is confusing and could be fixed.
If you want C.Y to really "hide" A.Y, you can use the new modifier, as in "new public void Y()" in the declaration.