In the first throw(Kid (3)) object of type Kid is created, therefore, P()K() will appear on the screen. This throw is caught in the catch(Parent ob), but the catching is done by the value of the object, i.e., a copy of Kid(3) is created, so the line ob.setx(15); will not change the original object created by Kid(3). Then exception is thrown up: (throw;) passing implicitly object Kid(3). This exception is caught (in the bottom) catch(Kid ob) and the value of the _x = 3 is displayed.
Thus the result will be P()K()3
Login in to like
Login in to comment