Hi guys, I have absolutely no idea what goes on in this code: Glenn, Mitchell.
OCAJP Oracle Certified Associate
Java SE 8 Programmer Practice Exams (Kindle Locations 11714-11716). Enthuware. Kindle Edition.
Consider the following classes :
Identify options that will compile and run without error. Select 1 option
A. a = (B)( I) b;
B. b = (B)( I) a;
C. a = (I) b;
D. I i = (C) a;
I just have no idea what I've read here. Is there any sort of easy way to get my head around this mess of double casting objects to other references etc? Generally speaking I've noticed that I have quite a few problems with these kind of questions, and I'm not sure how to tackle them really, I usually draw the hierarchy on a piece of paper but still, it's questions like these that really confuse me. How do I know that one or the other compiles and run? Is ther some kind of general rule I can apply? he correct answer is A by the way