The answer is:
Show method in Test class
Show method in Q2 class
Show method in Test class
Show method in Q2 class
Can some one explain me how the last 2 outputs are there.
Adam
SCJA, SCJP 5.0, SCWCD 1.4, SCBCD 5, SCEA 5
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Test1 t12=new Test1();
q1 = (Q2)t12; //throwing error saying the classcast exception how
//q = (Q2)t; is working fine.
q1.show();
can i say that before casting any reference variable to a particular type ,we need to make the reference variable to point to the object or reference of that particular type.
Consider Paul's rocket mass heater. |