Q2 extends Test, so it's always true that an instance of Q2 IS-A Test. But an instance of Test is not always a Q2.
So assigning t = q (an upcast) is always safe. But assigning q = t (a downcast) is not always safe, so an explicit cast is required to avoid a compilation error.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Joined: May 11, 2005
Hi, Just a comment or two....firstly, you should not access static methods using an instance reference, you should use the class reference. Secondly, you cannot override static methods (you may redefine them but the polymorphic behaviour you get with instance methods will not be present). Based on your code you you posted it looks like you would be expecting.....