求救!面试题!该如何解决

求救!面试题!!!Object-orientedDesign:ExplainanddemonstratetheconceptofInheritanceandPolymorphismusin

求救!面试题!!!
•Object-oriented   Design:   Explain   and   demonstrate   the   concept   of   Inheritance   and   Polymorphism   using   the   following   pseudo   Java   /   C#   /   C++   example:
oBase   Class:   Class   A,   has   method   “print”   that   outputs   “Class   A”
oDerived   Class:   Class   B   :   A,   has   method   “print”   that   outputs   “Class   B”
oJava   /   C#
A   Instance1;   Instance1   =   new   A   ();   Instance1.print()   //   output   =   ?
A   Instance2;   Instance2   =   new   B   ();   Instance2.print()   //   output   =   ?
A   Instance3;   Instance3   =   (A)   new   B   ();   Instance3.print()   //   output   =   ?


[解决办法]
A Instance1; Instance1 = new A (); Instance1.print() // output = “Class A”
A Instance2; Instance2 = new B (); Instance2.print() // output = “Class B”
A Instance3; Instance3 = (A) new B (); Instance3.print() // output = “Class B”