Question 9 from
www.jiris.com Exam 1 asks:
What is the output of trying to compile and run the following?
1: public class Test009 extends T
2: {
3: public static void main(
String args[])
4: {
5: Test009 t = null;
6: T tt = (T)t;
7: System.out.print(t);
8: System.out.print(" ");
9: System.out.println(tt);
10: }
11: }
12:
13: class T{}
The answer is code compiles and run with output: null null.
My question is why it is legitimate to type cast a null object reference (line 6) since there's no object exists?
Thank you very much