pradeep rajkumar wrote:Hi,
When i compiled and ran the below code,
I got a Runtime Exception as below,
Its just an ordinary Downcasting right ?
Then why this Exception was thrown ?
You cannot downcast an actual parent object to a child object. The cast will only work if the reference variable is of the parent type but the actual object being referred to is of the child type. So, the acutal object Tree cannot be cast to a child object (Redwood).