Casting is a runtime operation, and at runtime generic type arguments are erased. So type parameters without an upper bound just act as regular Object types. Here's what your class looks like at runtime:
Joined: May 18, 2012
Ok got it thank you
that means we can also cast a boolean type right???
Stephan van Hulst
Joined: Sep 20, 2010
You can cast to any generic type parameter, as long as the upper bound is a supertype of the reference you're casting. It doesn't really make much sense though, because you'd always be casting upwards, which is useless.
For instance, if the class signature was public class ImplicitConv<T extends String> then the program would throw a ClassCastException, as expected.
However, there is a compiler warning ("unchecked cast") on line 7. The compiler has been able to tell something was amiss and told you so. If you ignore or don't resolve generics-related compiler warnings, you risk getting ClassCastException at runtime.