Downcasting is _______________________ A. Always safe B. Never


Downcasting is _______________________

A. Always safe

B. Never safe

C. Safe sometimes

D. Safe, depending on code

I had been asked this question during an interview.

This question is from Downcasting in section Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming

Right choice is B. Never safe

For explanation: The downcasting concept is made for exception cases. When there is a need to represent an entity in the form which is not suitable for it. Representing a base type in derived type is not right but can be done for special cases.