6. Object o = (Object)new Foo(); \\ confusion 1
7. Foo foo = (Foo)o; \\ confusion 2
8. System.out.println(�i = � + foo.i);
Line 6 : Cast is not necessary as
Marc has pointed out.
Line 7 : Cast is must, to compile the code, there wont be any problem at
run time because the run time type of the o will be Foo object so
assigning Foo object to Foo ref variable is OK.
Line 8: foo.i is OK.
o.i //compiler error
((Foo)o) .i; //OK
Thanks,