1.

When is the downcasting used?(a) To separate inherited class from base class(b) To write a more complex code(c) To compare two objects(d) To disable one class in inheritanceI have been asked this question during a job interview.I'm obligated to ask this question of Downcasting in section Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming

Answer»

Right choice is (c) To compare two objects

Easiest explanation - The downcasting can be used WHENEVER there is a need to compare ONE object to another. Equals() function can be used to compare whether the objects were of same age. We can USE GETCLASS() function too.



Discussion

No Comment Found

Related InterviewSolutions