Code: Select all
Object o = a; Runnable r = (Runnable) o;
Option 5 says:
Code: Select all
Object o = b; Runnable r = (Runnable) b;
My Confusion:
While Option 5 says that the compiler can figure out that b will always point to an object of Runnable. I was wondering why not the same applicable for Option 2? Why does Option 2 require explicit casting?
I am not an experienced JAVA developer and trying to learn. May be I am missing something here. Appreciate if any one can assist me to understand.
With regards,
Arul