This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
hi.. I am posting my opinion on downcasting concept... pls follow this code first..
Downcasting ony possible at runtime(as I know)
Steps to Dwonccast::
1)Subclass reference varibale must be initialized Ex: rose r=new rose(); 2)The superclass reference varible MUST CAST TO (either explicitly or implicitly) SUBCLASS OBJECT... Ex: f=r; where f is superclass reference variable... r is subclass reference variable If not ...runtime error 'ClassCastException' occurs 3)Now we can downcast explicitly..
Is my conclusion correct or not....pls post your comments on downcasting. Tahnk You
that can be simply said as ,downcasting an superclass reference variable to an subclass reference variable is possible only if the super class variable actually refers to an instance of subclass or an subclass of the subclass....down the hierarchy