What will this program output? 2 What will be printed by the following code? Con
ID: 3744000 • Letter: W
Question
What will this program output?
Explanation / Answer
The output contains 3 lines given below
Figure
Rectangle
Box
-----------
Explanation
------------
Since both Rectangle and Box inherit from Figure class, the objects of these classes can be assigned to variable f of Figure type. The display() function is overriden in both Rectangle and Box and these new definitions are called instead of the one in the Figure class