Java | Class and Object | Question 5
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