Predict the output of the following program.
(A) Compilation error
Inside First Inside Second
Inside First Inside First
(D) Runtime error
Explanation: ‘ref’ is a reference variable which obtains the reference of object of class First and calls its function display().
Then ‘ref’ refers to object of class Second and calls its function display().
Quiz of this Question
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.